From the fish manual:

[The File Descripter may be] an ampersand followed by a minus sign (&-). The file descriptor will be closed

From the Arch wiki:.

Silencing standard output: $ command > &-

From this I expected it to act like an alias for /dev/null, but quick experimentation on the command line reveals that this is not so:

$ echo hello >&-  
Error while writing to stdout
write_loop: Bad file descriptor

Also, oddly if we add a space before the & we get a a different error:

$ echo hello > &-
Expected a string, but instead found a '&'

What on earth is going on here? I'm running fish 2.2.0

  • 3
    The documentation that you quoted says it is closed. Writing to a closed file descriptor generates an error, which is reported (on the standard error of course - a different file descriptor). – Thomas Dickey Nov 1 '15 at 20:48

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.