|| 是什么意思? .screenrc 中的意思是什么?

发布于 2024-07-26 07:23:50 字数 425 浏览 5 评论 0原文

基于Rampion命令

screen /bin/sh -c '/usr/bin/man `cat "$@"` > /tmp/manual | less /tmp/manual || read'

<代码>|| read 并不意味着命令中的read 似乎是一个内置命令,我在 OS X 手册中没有找到相关解释。

命令中的||是什么意思?

Command based on Rampion's command

screen /bin/sh -c '/usr/bin/man `cat "$@"` > /tmp/manual | less /tmp/manual || read'

|| read does not mean or in the command. read seems to be a built-in -command about which I did not find explanation in my OS X's manuals.

What does || mean in the command?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

尘世孤行 2024-08-02 07:23:50

|| 几乎是“或”运算符。

在上面的代码示例中,它将首先运行 less /tmp/manual,如果返回的值不正确,它将运行 read。 如果第一个命令返回真值,则由于短路而不会执行读取命令。

感谢 Michiel:请注意,该运算符不是可交换的,因此它不是数学或。

|| is nearly 'or' operator.

In the code example above it will first run less /tmp/manual and if it returns a value that is not true it will run read. If the first command returns a true value then the read command is not performed because of short circuiting.

Thanks to Michiel: please note that the operator is not commutative such that it is not mathematical OR.

月亮是我掰弯的 2024-08-02 07:23:50

米特马罗说的话。 它是 shell 的参数,在本例中是 /bin/sh。 (从技术上讲,它不是一个“参数”(这是一个不同的术语),但它是 shell 的“语法”的一部分。)

有关详细信息,您可以阅读 sh 上的手册页。 您要查找的内容位于“列表”部分下。

片段:

OR 列表的形式为

<前><代码>命令1 || 命令2

当且仅当命令1返回非零时才执行命令2
退出状态。

AND 和 OR 列表的返回状态是最后一个列表的退出状态
在列表中执行的命令。

What MitMaro said. It's a parameter for the shell, or /bin/sh in this case. (Technically it's not a "parameter" (that's a different term) but it's part of the shell's "grammar.")

For details, you can read the man page on sh. What you're looking for is under the "Lists" section.

Snippet:

An OR list has the form

command1 || command2

command2 is executed if and only if command1 returns a non-zero
exit status.

The return status of AND and OR lists is the exit status of the last
command executed in the list.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文