如果语句说明,则-t标志在shell脚本中是什么意思?
我不确定-t标志对Unix Shell脚本的含义是什么,因为我在网上找不到任何提及。
我遇到了一个if语句,以获取bash shell shell脚本。我包括了一个消毒的片段:
source "${BASH_SOURCE%/*}"/some_script
if [[ ! -t 0 ]] && [[ $(id -u) == 0 ]]; then
echo 'got here'
else
echo 'no get here'
fi
我不明白测试命令中的“ -t”标志。我认为它与测试文件没有任何关系,因为它与我发现的其他文件测试标志没有出现,并且因为0不是文件。
提前致谢。
I'm not sure what the -t flag means for unix shell scripts since I can't find any mention of it online.
I ran into an if statement for a bash shell shell script. I've included a sanitized snippet:
source "${BASH_SOURCE%/*}"/some_script
if [[ ! -t 0 ]] && [[ $(id -u) == 0 ]]; then
echo 'got here'
else
echo 'no get here'
fi
I don't understand what the "-t" flag in the test command. I assume it doesn't have anything to do with testing files since it didn't appear with the other file testing flags I found and because 0 is not a file.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
-t
表示:在这种情况下,文件描述符0是标准输入,因此检查标准输入是否来自终端。
有关这些文件描述符的完整列表,请运行
MAN BASH
并搜索“条件表达式”。-t
means:In this case, file descriptor 0 is standard input, so it's checking to see if standard input is coming from the terminals.
For a complete list of these file descriptors, run
man bash
and search for "CONDITIONAL EXPRESSIONS".