检查Fish中是否有重定向

时间:2014-03-16 20:56:48

标签: linux shell fish

我正在为fish-shell编写一个应该表现得像这样的简单函数:

theFunc someArguments
somecommand | theFunc

我正在寻找一种方法来了解是否使用管道 / 重定向调用了该函数。
你有这个想法吗?

谢谢!

1 个答案:

答案 0 :(得分:2)

如果有人需要,我正在设置信息。

正如Ben Voigt指出的那样,我们应该使用isatty函数 对于 fish-shell ,您只需检查:

if isatty stdin
    # Your code here.
end