我正在为fish-shell
编写一个应该表现得像这样的简单函数:
theFunc someArguments
somecommand | theFunc
我正在寻找一种方法来了解是否使用管道 / 重定向调用了该函数。
你有这个想法吗?
谢谢!
答案 0 :(得分:2)
如果有人需要,我正在设置信息。
正如Ben Voigt指出的那样,我们应该使用isatty
函数
对于 fish-shell ,您只需检查:
if isatty stdin
# Your code here.
end