0

By convention, stdout is -. Is there something similar for stderr?

midrare
  • 153
  • 1
    - can be a place holder for stdout in contexts that expect a file that is written to (like tar cf -), or stdin in contexts that expect a file that is read from (like paste -, diff - file) or several other things. For instance for cd, - means the previous directory. - is also use as the option delimiter for most Bourne-like shells and builtins of the Bourne/Korn/Z shells. See also patch -r - where - means discard – Stéphane Chazelas Mar 03 '23 at 06:36
  • 1
    Can you think of any place where a similar thing as - could be useful for representing the standard error stream? – Kusalananda Mar 03 '23 at 06:38
  • No, but if you want to pipe stderr into a program, see Piping STDERR vs. STDOUT and Pipe STDOUT & STDERR separately. There are also lots of other questions and answers about piping stderr on this site. – cas Mar 03 '23 at 11:50
  • @Kusalananda It's for a CLI argument for a program of mine. I want to allow the user to configure where certain log messages go. A - filename directs certain messages to stdout. I want something similar for stderr. – midrare Mar 03 '23 at 22:25
  • @StéphaneChazelas This has no relevance to the question. – midrare Mar 03 '23 at 22:26
  • Hmmm... I'm not sure I understand the semantics. If certain messages are sent to a file whose argument can be - to signify standard output, what would stop you from sending error messages to the standard error stream and letting the user redirect that? Or do you need a filename? It would be good to see a real application that would require this. Some utilities use -o and -e as options taking arguments that are filenames where the utility will save output and error messages, but it's uncommon. These would just use stdout and stderr as usual if the options were not given. – Kusalananda Mar 03 '23 at 22:36

0 Answers0