bash命令XOR ^ anothercommand

AK_*_*AK_ 2 linux bash operators delimiter logical-operators

在下面的示例中:

w ^ ls
Run Code Online (Sandbox Code Playgroud)

Shell中XOR运算符的预期行为是什么?

所以当我们进入

command ^ anothercommand
Run Code Online (Sandbox Code Playgroud)

有哪些触发器anothercommand可以运行(如果将完全执行)?

che*_*ner 7

如果您输入command ^ anothercommand,则只需提供command两个参数^anothercommand。这里没有操作员。anothercommand仅当command决定将该参数视为命令名称并尝试运行它时才会运行。

  • @AK_:是的,例如“echo ^” (2认同)

cho*_*oba 5

正如您在中看到的man bash^它不用于分隔命令,而是在算术表达式内部使用。

$ echo $(( 5 ^ 9 ))
12
Run Code Online (Sandbox Code Playgroud)

那是因为

dec     bin
 5     0101
 9     1001
-----------
12     1100
Run Code Online (Sandbox Code Playgroud)

  • 我不明白一个不存在的操作员如何会导致安全问题。 (2认同)