почему bash не выходит из-за ошибки синтаксиса теста? - PullRequest
0 голосов
/ 30 марта 2020

Я бы хотел, чтобы скрипт завершился при синтаксической ошибке, возникающей в тесте, но не повезло:

bash -n "$0" || exit  # check script syntax

#set -xv
set -o nounset
set -o errexit
set -o pipefail # make pipes fail if one of the piped commands fails

if (( != 0 )); then  # syntax error here
  echo "after if"
fi

echo "should not reach this point, but indeed does"

Вывод:

./testscript: line 8: ((: != 0 : syntax error: operand expected (error token is "!= 0 ")
should not reach this point, but indeed does

какое-либо решение? спасибо

...