I was debugging a shell script, and the problem was that the following code
if curl doesntexist -i &> /dev/null;
then
echo True
else
echo False
fi
Is, if running zsh, not equivalent to:
if curl 6 -i 1> /dev/null 2> /dev/null;
then
echo True
else
echo False
fi
The later echos True as expected, but if I redirect with &>, the output is false. I do not understand this behaviour, for example here it says that
&>name is like 1>name 2>name
Can someone explain why the two snippets do not behave the same if running in zsh? From zsh docu it says that it should also redirect stdout and stderr, sounds like it should do the same as in bash:
&> Redirects both standard output and standard error (file descriptor 2) in the manner of ‘> word’