On 7/30/24 8:49 AM, Justus wrote:
Hello bash team!I found a bug in my beloved bash and hope that you can fix it! Everything else is described in the attached bashbug.txt
Word expansions like command substitution are run in the context of the shell instance performing the expansion, which means that the child forked to run the command substitution inherits things like open file descriptors from its parent. So if you have something like seq 3 | head -n $(calc -dp "1+1") the piping has already occurred by the time the child process forked to run the final element of the pipeline performs the word expansion. If the command substitution contains a process (like, apparently, `calc') that reads from its stdin, it will consume the data and leave it unavailable to its caller. I suspect that zsh and fish act as you expect because they perform the word expansion before making the pipe the standard input for the final pipeline element. -- ``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/
OpenPGP_signature.asc
Description: OpenPGP digital signature