Continuing
如果我删除子外壳,下面的代码会打印出来。:
使用 subshell ,如果我想进入该Continuing
部分,我需要在测试后再次成功调用(使用成功的 no-op 命令是最直接的,IMO)。
#!/bin/sh
set -e #Exit on untested error
( #Subshell
#Some succesfful commands go here
#And here comes a file test
[ -f "doesntExist" ] && {
: #Irrelevant
}
#:
)
echo Continuing
这种行为正确吗?为什么引入子shell会改变
[ -f "doesntExist" ] && {
:
}
我正在使用dash 0.5.7-2ubuntu2
来运行它。