为什么不工作?
test $? -eq 1 || $(echo "hello"; echo "hi")
我得到以下错误:
Command 'hello' not found, but can be installed with:
snap install hello # version 2.10, or
apt install hello # version 2.10-2ubuntu4
apt install hello-traditional # version 2.10-5
See 'snap info hello' for additional versions.
您要找的是3.2.5.3分组命令
test $? -eq 1 || { echo "hello"; echo "hi"; }
括号周围的空格和后面的分号(或换行符)是必需的。
但是,不要使用$?
变量测试退出状态(很容易不小心在那里插入另一个命令)
直接使用命令
some command here && { echo hello; echo hi; }