Is there a "-" if stdin has a specific name?

In several command line applications, if you connect stdin to them, you need to specify the character - instead of the input file.

Example:

 $ foo | bar - 

Now I'm wondering: does this symbol have - official special name when used in this context, for example. dotted stdin operator or something like that? If so, which one?

The background of my question is that I want to write a function that detects this character and then treats stdin accordingly, instead of parsing the arguments as an array, and I was wondering what to call this function.

+5
source share
1 answer

The POSIX standard does not use a special name for using the - character. It says:

For utilities that use operands to represent files that need to be opened for reading or writing, the operand '-' should be used to indicate only standard input (or standard output when it is clear from the context that the output file is specified) or a file named -.

and then

If the utility described in the Shell and Utilities volumes of POSIX.1-2008 that complies with these recommendations is required to accept or not accept the operand "-" to indicate standard input or output, this explanation is explained in the OPERANDS section. Otherwise, if such a utility uses operands to represent files, it is determined by the implementation whether the "-" operand is standard input (or standard output) or for a file named -.

There is also no special name on the manual pages:

If no files are specified, or if a "-" file is specified, grep searches for standard input.

So you need to come up with your name.

+2
source

Source: https://habr.com/ru/post/1215516/


All Articles