New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document pipe, redirection, and semicolon properly. #5319
Comments
It's done left-to-right. Fish checks the first, sees ">/dev/null", sets stdout to go to /dev/null. It sees Fish checks the second, sees "^&1" and sends stderr to where stdout is at that moment going, which is the terminal (unless it's already redirected from the outside). It goes on, sees ">/dev/null" and sends stdout to /dev/null, keeping stderr pointing to the terminal. Imagine "&1" expanding to where stdout is going at that moment.
The redirection is done after the pipe, so stdout is redirected to the pipe, and stderr is then redirected to where stdout is going, which is the pipe. So the first pipes both. The latter applies Also note that 3.0 deprecates the "^" redirection in favor of the standard "2>", so that last example should be As far as I know, this is the same as POSIX shells (e.g. bash). In general I agree that our documentation too often assumes knowledge of that. |
What about |
That's a syntax error, because the $ cmd | 2>&1 cmd2
fish: Expected a command, but instead found a redirection
cmd1 | 2>&1 cmd2
^ If we did allow redirections to appear before the command (POSIX does, it's not used much), it would apply to the stderr of "cmd2", which would send it to its stdout, which by default would be the terminal anyway. |
cmd1 ^&1 | cmd2
is not the same ascmd1 | cmd2 ^&1
cmd1 >/dev/null ^&1
orcmd1 ^&1 >/dev/null
|
,>
, and;
.POSIX shell specification describes syntax in nauseating details, but those details are very disorienting. Bash documentation describes syntax well.
The text was updated successfully, but these errors were encountered: