Re: Can't wait for process substitution redirected for a subshell
On 4/24/18 4:46 PM, Geir Hauge wrote: > Waiting on a process substitution that is used in redirection for a > command grouping works, but not when using a subshell in place of that > command grouping: > > $ TIMEFORMAT=%R > $ time bash -c '{ :; } 2> >(sleep 2); wait "$!"' > 2.013 > $ time bash -c '(:) 2> >(sleep 2); wait "$!"' > bash: line 0: wait: `': not a pid or valid job spec > 0.008 > > I'd expect those two cases to behave the same way. > > It looks like the redirection is done after the subshell is forked, so > adding the wait inside the subshell actually works: Yes, expansion and redirections are performed in a subshell when the shell executes a subshell command. Bash has always behaved like this, and I don't foresee changing it. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
[BUG] persistently assigned variable cannot be unexported in POSIX mode
POSIX allows assignments preceding special builtins such as ':', 'set', etc. not only to persist but also to be persistently exported. I think that exporting behaviour is inherently broken and it's unfortunate that bash does this in POSIX mode, as it's merely allowed and not actually mandated, but anyway... What I'm reporting here is a bug I discovered with unexporting a variable that is so exported while bash is in POSIX mode. It cannot be unexported using 'typeset +x' if you try to do that in a shell function. This works: $ bash -o posix -c 'foo=abc : ; typeset +x foo; env|grep ^foo=' (no output, as expected: no longer exported) But this doesn't: $ bash -o posix -c 'fn() { foo=abc : ; typeset +x foo; env|grep ^foo=; }; fn' foo=abc Bug confirmed on all bash versions down to 2.05b. I've also succeeded in making 'unset -v' fail silently for a variable that is so exported, but I've so far been unable to track down a specific reproducer that is simple enough to post here. It occurred as a failure in the modernish regression test suite, which is extensive. Chet, let me know if you want a reproducer for that and I'll email you a tarball plus instructions. It seems likely that fixing the bug reported above would fix that one as well, though. - M.