Update: And I think I've been using the shell direction wrong, because it understands it if I redirect the filehandles in a different order: ... But that this is wrong and I need to do it the other way around.
Indeed. It does seem somewhat backwards, but it has always been that way.
When 2>&1 is seen, stderr is redirected to wherever stdout is pointing at that time. If you then redirect stdout somewhere else, stderr is not then re-redirected.
So if you want to redirect both to the same place, you have to redirect stdout first; then 2>&1 does the expected thing.
In reply to Re^7: The importance of avoiding the shell
by BrowserUk
in thread The importance of avoiding the shell
by jhourcle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |