I'd like to log standard output and standard error separately in .xprofile using logger. In Bash I think that would look something like this:exec 1> >(logger --priority user.notice --tag $(basename $0)) \     2> >(logger --priority user.error --tag $(basename $0))How would I do that in a POSIX /bin/sh compatible manner?
How to send all output to `logger` in POSIX shell?
shell;pipe;posix
There's no POSIX equivalent. You can only perform a redirection with exec, not a fork. A pipe requires a fork, and the shell waits for the child to finish.One solution is to put all your code in a function.all_my_code () {  }{ all_my_code |  logger --priority user.notice --tag $(basename $0); } 2>&1 |   logger --priority user.error --tag $(basename $0)(This also logs any error from the stdout instance of logger to the stderr instance. You can avoid this with more file descriptor shuffling.)If you want the parent shell to exit even if the logger processes are still running, put & at the end of the logger invocations.{ all_my_code |  logger --priority user.notice --tag $(basename $0) & } 2>&1 |   logger --priority user.error --tag $(basename $0) &Alternatively, you can use named pipes.pipe_dir=$(mktemp -d)mkfifo $pipe_dir/out $pipe_dir/err<$pipe_dir/out logger --priority user.notice --tag $(basename $0) &<$pipe_dir/err logger --priority user.error --tag $(basename $0) &exec >$pipe_dir/out 2>$pipe_dir/err rm -r $pipe_dir