- 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 ChazelasMar 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?
– KusalanandaMar 03 '23 at 06:38
@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.
– midrareMar 03 '23 at 22:25
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.
– KusalanandaMar 03 '23 at 22:36
-
can be a place holder for stdout in contexts that expect a file that is written to (liketar cf -
), or stdin in contexts that expect a file that is read from (likepaste -
,diff - file
) or several other things. For instance forcd
,-
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 alsopatch -r -
where-
means discard – Stéphane Chazelas Mar 03 '23 at 06:36-
could be useful for representing the standard error stream? – Kusalananda Mar 03 '23 at 06:38-
filename directs certain messages to stdout. I want something similar for stderr. – midrare Mar 03 '23 at 22:25-
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