Просмотр исходного кода

fix(core): keep the exit code when core_exit.sh is downloaded on exit (#5192)

Downloading a missing core_exit.sh ran it from inside fn_fetch_file, which declares its own local exitcode for the curl result, so the exit code from before the download was lost and a failed command exited 0 the first time core_exit.sh was fetched. Download it first with fn_update_module, keep the real exitcode across that download, then load it as before.

Fixes #5191
BorzakA 1 день назад
Родитель
Сommit
eb8f34aea3
1 измененных файлов с 7 добавлено и 0 удалено
  1. 7 0
      lgsm/modules/core_modules.sh

+ 7 - 0
lgsm/modules/core_modules.sh

@@ -23,6 +23,13 @@ core_dl.sh() {
 
 core_exit.sh() {
 	modulefile="${FUNCNAME[0]}"
+	# Download core_exit.sh without running it first. fn_fetch_file declares a local exitcode
+	# while downloading, so running it from there would exit with that instead of the real one.
+	if [ ! -f "${modulesdir}/${modulefile}" ]; then
+		local exitcodesaved="${exitcode}"
+		fn_update_module
+		exitcode="${exitcodesaved}"
+	fi
 	fn_fetch_module
 	exitcode=$?
 	if [ "${exitcode}" -ne 0 ]; then