I already know the proper way to redirect stderr and stdout in CMD and BASH. Trying to get an understanding of the logic of the various shells/environments etc. In previous discussions on this topic, people were using some form of logic to explain why/how it works in a specific shell/environment. But that logic doesn't apply across the various shells/environments. Since the logic applied for one doesn't hold up for the other then logic applied to any of these is inadequate. And that is what makes it confusing for a noob such as myself. I'm getting a little deep here though. When reading about redirection, I ran across this example for CMD/batch in windows, and appears to be very similar behavior in Bash:
command > file 2>&1
In the documentation it states that is the correct way to redirect stderr to stdout and then stdout to a file. It also seems that one would tend to choose
command 2>&1 >filename
but this syntax will fail. After way to much time spent trying to understand the logic of this and finally coming to terms with it, I run across this world crashing example for powershell:
dir 'C:\', 'fakepath' 2>&1 > .\dir.log
This clearly goes against the logic for the former examples. This topic has been beaten to death it appears, even on this site. So if using "logic" and it doesn't apply to other shells how do folks manage to remember these subtle differences between shells?