mvdan / sh

A shell parser, formatter, and interpreter with bash support; includes shfmt
https://pkg.go.dev/mvdan.cc/sh/v3
BSD 3-Clause "New" or "Revised" License
6.97k stars 332 forks source link

Process Substitution Locks Shell #1032

Open leath-dub opened 9 months ago

leath-dub commented 9 months ago

This is easily reproducible even on the master branch run the following

ls <(echo hello)

This should just print a temp path, however It ends up locking the shell - only responding to Ctrl-c.

theclapp commented 9 months ago

It's not completely broken. gosh appears to wait until something reads the FIFO it creates (whereas bash doesn't care). If you do that, it works:

$ cat <(echo .)
.

If you cat the FIFO in a different shell, that unblocks gosh:

<<<window 1>>>
$ ls -l <(echo .)
prw-r--r--@ 1 lmc  staff  0 Sep 16 11:35 /var/folders/9d/vt3kqx293xx8w3tn8m1jy_wc0000gn/T//sh-interp-12e05f50832eb231
<gosh blocks>

<<<window 2>>>
$ cat /var/folders/9d/vt3kqx293xx8w3tn8m1jy_wc0000gn/T//sh-interp-12e05f50832eb231
.
$

<<<window 1>>>
<gosh unblocks>
$