Re: Command substitution optimisation in dot scripts

2016-09-30 Thread Stephane Chazelas
2016-09-30 04:49:33 +0100, Martijn Dekker: [...] > my_subshell_pid=$(sh -c 'echo $PPID') > > This works fine on every shell, except on bash when a dot script is > being executed. [...] While it does look like a bug, you could always do: my_subshell_pid=$(exec sh -c 'echo $PPID') To be sur

Re: Racing condition leads to unstable exit code

2016-09-30 Thread Chet Ramey
On 9/29/16 10:58 PM, Luiz Angelo Daros de Luca wrote: > No problem! I already workarounded it using pipe as a semaphore. Thanks! > > It's there any chance of changing the 128+signal exit code for wait when > trap is received? > It might solve some special usecase which I'm not aware. Wait should a

Re: Command substitution optimisation in dot scripts

2016-09-30 Thread Chet Ramey
On 9/29/16 11:49 PM, Martijn Dekker wrote: > I detected an oddity (possible bug) in bash: the usual optimisation for > launching external processes in simple command substitutions is turned > off while executing a dot script. > > Background: For reasons that would take too much space to explain he

Re: Racing condition leads to unstable exit code

2016-09-30 Thread Luiz Angelo Daros de Luca
Yes, this is the part that I agree. However, this is the other behavior of bash wait (from bash manual) "When Bash is waiting for an asynchronous command via the wait builtin, the reception of a signal for which a trap has been set will cause the wait builtin to return immediately with an exit sta

Re: Racing condition leads to unstable exit code

2016-09-30 Thread Chet Ramey
On 9/30/16 10:11 AM, Luiz Angelo Daros de Luca wrote: > Yes, this is the part that I agree. However, this is the other behavior of > bash wait (from bash manual) > > "When Bash is waiting for an asynchronous command via the wait builtin, the > reception of a signal for which a trap has been set wi

Re: Racing condition leads to unstable exit code

2016-09-30 Thread Reuti
Hi, > Am 30.09.2016 um 16:11 schrieb Luiz Angelo Daros de Luca : > > Yes, this is the part that I agree. However, this is the other behavior of > bash wait (from bash manual) > > "When Bash is waiting for an asynchronous command via the wait builtin, the > reception of a signal for which a tra

Re: Command substitution optimisation in dot scripts

2016-09-30 Thread Chet Ramey
On 9/29/16 11:49 PM, Martijn Dekker wrote: > I detected an oddity (possible bug) in bash: the usual optimisation for > launching external processes in simple command substitutions is turned > off while executing a dot script. Thanks for the suggestion. I added the optimization to command substitu