First of all, redirections can occur anywhere in the command line, not necessarily at the end or start.
echo foo >spamegg bar
foo bar in the file
Also, there are two versions of
which, one is shell builtin and the other is external executable (comes with
debianutils in Debian).
In your command:
which lsb_release 2>&1 /dev/null
2&>1, you are redirecting the STDERR (FD 2) to where STDOUT is (FD 1) pointed at, not to
/dev/null and this is done first.
So the remaining command is:
which lsb_release /dev/null
As there is no command like
/dev/null, hence the error.
Note that, this behavior depends on whether
which is a shell builtin or external executable,
dash do not have a builtin and use external
which and that simply ignores the error, does not show any error message.
On the other hand,
zsh uses a builtin
which and shows:
/dev/null not found
So presumably, that specific error is shown by the builtin
which of the shell you are using.
Also, it seems you wanted to just redirect the STDERR to
lsb_release does not exist in the
which shows an error. If so, just redirect the STDERR to
which lsb_release 2> /dev/null