如果代表 stdin,'-' 是否有特定名称?
Does '-' if standing for stdin have a specific name?
在一些命令行应用程序中,如果将标准输入通过管道输入它们,则需要提供 -
字符而不是输入文件。
样本:
$ foo | bar -
现在我想知道:这个 -
字符在这种情况下是否有一个正式的特殊名称,例如虚线标准输入运算符 或类似的东西?如果有,是哪一个?
我的问题背景是想写一个函数检测这个字符然后对stdin进行相应的处理,而不是将参数解析为数组,我想知道这个函数怎么调用。
POSIX 标准没有为 -
字符的这种用法使用任何特殊名称。它说:
For utilities that use operands to represent files to be opened for either reading or writing, the '-' operand should be used to mean only standard input (or standard output when it is clear from context that an output file is being specified) or a file named -.
然后
Where a utility described in the Shell and Utilities volume of POSIX.1-2008 as conforming to these guidelines is required to accept, or not to accept, the operand '-' to mean standard input or output, this usage is explained in the OPERANDS section. Otherwise, if such a utility uses operands to represent files, it is implementation-defined whether the operand '-' stands for standard input (or standard output), or for a file named -.
手册页似乎也没有使用任何特殊名称:
If no files are specified, or if the file "-" is given, grep searches standard input.
看来你得自己起个名字了
在一些命令行应用程序中,如果将标准输入通过管道输入它们,则需要提供 -
字符而不是输入文件。
样本:
$ foo | bar -
现在我想知道:这个 -
字符在这种情况下是否有一个正式的特殊名称,例如虚线标准输入运算符 或类似的东西?如果有,是哪一个?
我的问题背景是想写一个函数检测这个字符然后对stdin进行相应的处理,而不是将参数解析为数组,我想知道这个函数怎么调用。
POSIX 标准没有为 -
字符的这种用法使用任何特殊名称。它说:
For utilities that use operands to represent files to be opened for either reading or writing, the '-' operand should be used to mean only standard input (or standard output when it is clear from context that an output file is being specified) or a file named -.
然后
Where a utility described in the Shell and Utilities volume of POSIX.1-2008 as conforming to these guidelines is required to accept, or not to accept, the operand '-' to mean standard input or output, this usage is explained in the OPERANDS section. Otherwise, if such a utility uses operands to represent files, it is implementation-defined whether the operand '-' stands for standard input (or standard output), or for a file named -.
手册页似乎也没有使用任何特殊名称:
If no files are specified, or if the file "-" is given, grep searches standard input.
看来你得自己起个名字了