我想了解原因:
#!/bin/bash -e
main() {
local a=$(command_that_does_not_exist)
echo "This should not be printed $a"
}
main
输出:
/tmp/poc.sh: ligne 4: command_that_does_not_exist : commande introuvable
This should not be printed
我希望脚本在第4行停止并仅输出:
/tmp/poc.sh: ligne 4: command_that_does_not_exist : commande introuvable
此外,以下脚本可以正常工作:
#!/bin/bash -e
main() {
local a
a=$(command_that_does_not_exist)
echo "This should not be printed $a"
}
main