Opened 4 years ago
Last modified 3 years ago
#16907 new bug
Process substitution in Bash fails
Reported by: | aligator | Owned by: | nobody |
---|---|---|---|
Priority: | normal | Milestone: | Unscheduled |
Component: | - General | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
Hi The problem is related to this issue https://github.com/romkatv/gitstatus/issues/229. Basically it happens that the bash process substitution https://www.linuxjournal.com/content/shell-process-redirection doesn't work relyable in Haiku using bash or zsh.
I am not sure in which component exactly this issue belongs to. I am running Haiku Revision hrev55023.
Initially I noticed the problem in zsh and it can reproduced there with
zsh -fc 'zmodload zsh/system && sysopen -r -o cloexec -u fd <(true)'
Which fails to read the file the substitution creates.
can't open /tmp/zshpRfl6c: no such file or directory
Now this problem also appears to happen when using bash using a simpler variant:
~/projects/dev> bash --norc -c 'exec < <(true)' bash: cannot open named pipe /tmp//sh-np.qGCOgA for writing: No such file or directory
But interestingly
zsh -fc 'exec < <(true)'
works just fine.
But now the strangest thing about it is that
bash --norc -c 'exec < <(true)'
works sometimes, too. When I spam the command it happens to work in rare cases. This leads to my assumption that the "file" created by <(true) does not last long enough for the exec to read it in all cases. Also because the short zsh variant works mostly, I assume that it just executes it faster. But when running the initial command with sysopen it's too slow and the file is already closed when it tries to read it.
Also this
~/projects/dev> bash --norc -c 'cat <(echo hello)' hello
seems to work just fine.
As additional information it seems that a similar issue exists for other shell implementations, too: https://github.com/ish-app/ish/issues/164 Here ish has a similar problem and WSL1 had it also.
Thats all I found out so far.
Change History (4)
comment:1 by , 3 years ago
comment:2 by , 3 years ago
@cocobean
Just updated Haiku to rev55333, with bash 5.1.0(1). Nothing changed. the command
bash --norc -c 'exec < <(true)'
still fails in most cases.
But as this seems to be a race condition it may very likely be system-specific (e.g. faster cpu / ram).
Have you tried the first command?
zsh -fc 'zmodload zsh/system && sysopen -r -o cloexec -u fd <(true)'
Because that one fails for me in nearly all cases. (sometimes the first execution works)
comment:3 by , 3 years ago
Haiku R1B3 hrev55181+55 x86_gcc2
- bash 5.1-1
- zsh 5.7.1-2
zsh -fc 'zmodload zsh/system && sysopen -r -o cloexec -u fd <(true)'
- No errors.
bash --norc -c 'exec < <(true)'
- No errors.
@aligator - I tested this on Haiku R1B3 with bash 5.1.0(1) with no issues:
I spammed about 10 times without issue. Can you retest it?