Hi,
I do not know if this is a bug - so I do not know if I'm asking in the right place. But let me explain what I'm trying to do.
I want to check if a program exist and if not test for another program like this:
which yay || which pacman
If yay does no exists I get:
yay not found
to stdout with an error code of 1
which means that if can't redirect stderr to null
prog=$(which yay 2>/dev/null || which pacman)
So if yay does not exist prog becomes:
yay not found
/sbin/pacman
This is not the case if I for example do: ls non_existant_file, that results in:
ls: cannot access 'non_existant_file': No such file or directory
to stderr with error code of 2 and it's possible for me to do: ls non_existant_file 2>/dev/null
with an empty result.
So my question is, should which push it's error message to stderr instead? Or is the implementation as it should be?
Best regards,
Ka le