From 9e7d338098ed713026c1f91ac50b9e3158340304 Mon Sep 17 00:00:00 2001 From: Luca Moreno Louzada Date: Tue, 1 Oct 2024 10:18:27 -0700 Subject: [PATCH] #18 add exit 1 to run_xx errors --- lib/shell/run_R.sh | 4 ++-- lib/shell/run_latex.sh | 4 ++-- lib/shell/run_python.sh | 5 +++-- lib/shell/run_shell.sh | 3 ++- lib/shell/run_stata.sh | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/shell/run_R.sh b/lib/shell/run_R.sh index 34d78c6..5fa4072 100644 --- a/lib/shell/run_R.sh +++ b/lib/shell/run_R.sh @@ -20,7 +20,7 @@ run_R () { error_time=$(date '+%Y-%m-%d %H:%M:%S') echo -e "\033[0;31mProgram error\033[0m at ${error_time}: ${rCmd} not found. Make sure command line usage is properly set up." echo "Program Error at ${error_time}: ${rCmd} not found." >> "${logfile}" - return 1 # exit early with an error code + exit 1 # exit early with an error code fi # check if the target script exists @@ -28,7 +28,7 @@ run_R () { error_time=$(date '+%Y-%m-%d %H:%M:%S') echo -e "\033[0;31mProgram error\033[0m at ${error_time}: script ${program} not found." echo "Program Error at ${error_time}: script ${program} not found." >> "${logfile}" - return 1 + exit 1 fi # capture the content of output folder before running the script diff --git a/lib/shell/run_latex.sh b/lib/shell/run_latex.sh index a2c0ba2..c0b4655 100644 --- a/lib/shell/run_latex.sh +++ b/lib/shell/run_latex.sh @@ -43,7 +43,7 @@ run_latex() { error_time=$(date '+%Y-%m-%d %H:%M:%S') echo -e "\033[0;31mProgram error\033[0m at ${error_time}: latexmk not found. Ensure LaTeX is installed." echo "Program Error at ${error_time}: latexmk not found." >> "${logfile}" - return 1 + exit 1 fi # check if the target script exists @@ -51,7 +51,7 @@ run_latex() { error_time=$(date '+%Y-%m-%d %H:%M:%S') echo -e "\033[0;31mProgram error\033[0m at ${error_time}: script ${programname}.tex not found." echo "Program Error at ${error_time}: script ${programname}.tex not found." >> "${logfile}" - return 1 + exit 1 fi # capture the content of output folder before running the script diff --git a/lib/shell/run_python.sh b/lib/shell/run_python.sh index 19165c3..08a8023 100644 --- a/lib/shell/run_python.sh +++ b/lib/shell/run_python.sh @@ -20,7 +20,7 @@ run_python () { error_time=$(date '+%Y-%m-%d %H:%M:%S') echo -e "\033[0;31mProgram error\033[0m at ${error_time}: ${pythonCmd} not found. Make sure command line usage is properly set up." echo "Program Error at ${error_time}: ${pythonCmd} not found." >> "${logfile}" - return 1 # exit early with an error code + exit 1 # exit early with an error code fi # check if the target script exists @@ -28,7 +28,7 @@ run_python () { error_time=$(date '+%Y-%m-%d %H:%M:%S') echo -e "\033[0;31mProgram error\033[0m at ${error_time}: script ${program} not found." echo "Program Error at ${error_time}: script ${program} not found." >> "${logfile}" - return 1 + exit 1 fi # capture the content of output folder before running the script @@ -56,6 +56,7 @@ run_python () { echo -e "\033[0;31mWarning\033[0m: there was an error, but files where created. Check log." echo -e "\nWarning: There was an error, but these files were created: $created_files" >> "${logfile}" # log created files fi + exit 1 else echo "Script ${program} finished successfully at $(date '+%Y-%m-%d %H:%M:%S')" | tee -a "${logfile}" echo "Output: $output" >> "${logfile}" # log output diff --git a/lib/shell/run_shell.sh b/lib/shell/run_shell.sh index 933a042..2c65b8d 100644 --- a/lib/shell/run_shell.sh +++ b/lib/shell/run_shell.sh @@ -17,7 +17,7 @@ run_shell () { error_time=$(date '+%Y-%m-%d %H:%M:%S') echo -e "\033[0;31mProgram error\033[0m at ${error_time}: script ${program} not found." echo "Program Error at ${error_time}: script ${program} not found." >> "${logfile}" - return 1 + exit 1 fi # capture the content of the output folder before running the script @@ -45,6 +45,7 @@ run_shell () { echo -e "\033[0;31mWarning\033[0m: there was an error, but files where created. Check log." echo -e "\nWarning: There was an error, but these files were created: $created_files" >> "${logfile}" # log created files fi + exit 1 else echo "Script ${program} finished successfully at $(date '+%Y-%m-%d %H:%M:%S')" | tee -a "${logfile}" echo "Output: $output" >> "${logfile}" # log output diff --git a/lib/shell/run_stata.sh b/lib/shell/run_stata.sh index 6b06e22..01094a4 100644 --- a/lib/shell/run_stata.sh +++ b/lib/shell/run_stata.sh @@ -29,7 +29,7 @@ run_stata() { error_time=$(date '+%Y-%m-%d %H:%M:%S') echo -e "\033[0;31mProgram error\033[0m at ${error_time}: script ${program} not found." echo "Program Error at ${error_time}: script ${program} not found." >> "${logfile}" - return 1 + exit 1 fi # capture the content of output folder before running the script