Browse Source

[fix] manage - fix miss usage of 'set -e'

The philosophy of set -e is typically that it only exits upon uncaught
errors. Here, the presence of || outside the subshell seems to tell the shell
that the error inside the subshell is 'caught' and therefore set -e does not
cause an exit after false [1].

The shell does not exit if the command that fails is ... part of any command
executed in a && or || list except the command following the final && or ||, any
command in a pipeline but the last, or if the command’s return status is being
inverted with ! [2]

[1] https://unix.stackexchange.com/questions/296526/set-e-in-a-subshell
[2] https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html#The-Set-Builtin

BTW: fix error reported by 'make test.shell'

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Markus Heiser 4 years ago
parent
commit
3bd2f3dc81
1 changed files with 10 additions and 7 deletions
  1. 10 7
      manage

+ 10 - 7
manage

@@ -343,14 +343,17 @@ pyenv.install() {
     if pyenv.install.OK > /dev/null; then
     if pyenv.install.OK > /dev/null; then
         return 0
         return 0
     fi
     fi
-    pyenv
-    pyenv.OK || die 42 "error while build pyenv (${PY_ENV_BIN})"
 
 
     (   set -e
     (   set -e
-       build_msg PYENV "[install] pip install -e 'searx${PY_SETUP_EXTRAS}'"
-       "${PY_ENV_BIN}/python" -m pip install -e ".${PY_SETUP_EXTRAS}"
-       buildenv
-    ) || die 42 "error while pip install (${PY_ENV_BIN})"
+        pyenv
+        build_msg PYENV "[install] pip install -e 'searx${PY_SETUP_EXTRAS}'"
+        "${PY_ENV_BIN}/python" -m pip install -e ".${PY_SETUP_EXTRAS}"
+        buildenv
+    )
+    local exit_val=$?
+    if [ ! $exit_val -eq 0 ]; then
+        die 42 "error while pip install (${PY_ENV_BIN})"
+    fi
 }
 }
 
 
 pyenv.uninstall() {
 pyenv.uninstall() {
@@ -462,7 +465,7 @@ themes.simple() {
 PYLINT_FILES=()
 PYLINT_FILES=()
 while IFS= read -r line; do
 while IFS= read -r line; do
    PYLINT_FILES+=("$line")
    PYLINT_FILES+=("$line")
-done <<< $(pylint.FILES)
+done <<< "$(pylint.FILES)"
 
 
 # shellcheck disable=SC2119
 # shellcheck disable=SC2119
 main() {
 main() {