by fiddlerwoaroof · 5y ago · 0 comments
I think the redirection can come first, though (not at a computer to test):
< <( do_something ) while read . . . $ < <( echo foo ) while read -r f; do echo "$f"; done
-bash: syntax error near unexpected token `do'
$ < <( echo foo ) xargs echo
foo
$ bash --version
GNU bash, version 5.1.4(1)-release (x86_64-apple-darwin20.2.0)For documentation purposes, this is the exact thing I tried to run:
$ < <(echo hi) while read a; do echo "got $a"; done
-bash: syntax error near unexpected token `do'
$ while read a; do echo "got $a"; done < <(echo hi)
got hi
Maybe there is another way... $ zsh -c '< <(echo hi) while read a; do echo "got $a"; done'
got hi
My position isn't that it is a good reason to switch shells, but if you're using it anyway then it is an option.Bash uses /dev/fd when available, but also appears to have an internal implementation which silently creates named pipes and cleans them up. In Bash 5.0.18 on AIX, fake process substitution works just fine, in my testing.