Bash – What’s the purpose of 1> in exec 1> >(logger -s -t tagname) 2>&1

bashexecio-redirectionshell

I just stumbled over

exec 1> >(logger -s -t $(basename $0)) 2>&1

which is used to redirect the output of the current script to the system logger (in case you've never seen this, but are interested check out https://stackoverflow.com/questions/8888251/understanding-bash-exec-12-command to broaden your shell knowledge).

I am wondering why the 1> is necessary. It seems necessary because exec >(logger -s -t test) 2>&1 fails due to

bash: /dev/fd/63: Permission denied
bash: exec: /dev/fd/63: cannot execute: Permission denied

Omitting 1> is however what I'd do intuitively because exec >[some redirection target] already should be sufficient for the redirection according to the question linked above. 2>&1 then redirects the stderr to stdout as usual.

I'm using bash 4.4.19.

Best Answer

It is necessary (the extra >, not the 1, 1> could be simply written >). The >(...) process substitution will expand to something like /dev/fd/13 (a file name), and then > will redirect the standard output into it. Thence > >(...).