0

The following script results in error when called directly, but not when called with . ./test.sh:

% cat test.sh
echo "foo" |
tee >(rev)

% . ./process_subst_test.sh
foo
oof


% ./process_subst_test.sh 
./process_subst_test.sh: line 1: syntax error near unexpected token `('
./process_subst_test.sh: line 1: `echo "foo" | tee >(rev)'

% echo "foo" |
tee >(rev)
foo
oof

What is wrong about the process redirection syntax in the script?

Why results vary depending on how script is invoked?


My shell is:

% zsh --version
zsh 5.8.1 (x86_64-apple-darwin21.0)
wass rubleff
  • 163
  • 7
  • The `zsh` shell will run scripts with no `#!`-line using the `sh` shell. The `sh` shell does not understand `>(...)`. See the duplicate question. – Kusalananda Aug 04 '22 at 14:51
  • Thank you! Now I know what that `#!`-line is for, and that it is called `shebang`! – wass rubleff Aug 04 '22 at 21:15

0 Answers0