On 4/24/19 9:49 AM, Ilkka Virta wrote: > On 24.4. 16:37, Chet Ramey wrote: >> "Utilities other than the special built-ins (see Special Built-In >> Utilities) shall be invoked in a separate environment that consists of the >> following...[includes redirections specified to the utility]... > > It does say > > "Open files inherited on invocation of the shell, open files controlled by > the exec special built-in plus any modifications, and additions specified > by any redirections to the utility" > > which could also be read to apply only the open files themselves, not the > byproducts of finding out their names.
I think the POSIX language is crafted to allow both behaviors, and bash has always interpreted it to process redirections, including the expansions performed on the word, in the subshell forked to execute the command. > Anyway, as little as it's worth, Zsh seems to do it the same way Bash does, > all others leave the changed value visible. The SVR4.2 Bourne shell, as another data point, behaves like bash. Since it doesn't have arithmetic expansion, you have to use something it does handle internally, like ${n:=2}. I don't know what ksh88, the other POSIX historical reference implementation, does. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/