How to print to stderr in the sink?
1 answer
You can redirect the output to stderr, for example:
echo "Error: $argv[1] is not a valid option" 1>&2
As a reference, there are some common IO redirects that work in fish *.
foo 1>&2 # Redirects stdout to stderr, same as bash
bar 2>&1 # Redirects stderr to stdout, same as bash
bar ^&1 # Redirects stderr to stdout, the fish way using a caret ^
* The file descriptors for stdin, stdout and stderr are 0, 1, and 2.
* &
implies that you want to redirect to a file stream, not a file.
* Comparison of redirection in different shells (bash, fish, ksh, tcsh, zsh)
+7
source to share