GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — programmingWithPythonCode/_scripts_/pythonIgnoreErrors.sh at main · thomasWeise/programmingWithPythonCode Expand file tree/ Copy pathpythonIgnoreErrors.shMore file actions executable file ·25 lines (19 loc) · 1.01 KB / Copy pathpythonIgnoreErrors.shFile metadata and controlsexecutable file ·25 lines (19 loc) · 1.01 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 #!/bin/bash - # This program executes python but ignores the errors. # Argument $1: the directory in which the command should run # Argument $2: the file to run # We enforce strict error handling, i.e., fail on any unexpected error. set -o pipefail # trace errors through pipes set -o errtrace # trace errors through commands and functions set -o nounset # exit if encountering an uninitialized variable set -o errexit # exit if any statement returns a non-0 return value cd "$1" # Enter the folder inside of which we should run the program. # Switch of "exit-on-error", run the program, then switch it back on. set +o errexit # Turn off exit-on-error. python3 $2 2>&1 # Run the program exitCode="$?" # Store exit code of program in variable exitCode. set -o errexit # Turn exit-on-error back on. # Convert exit code to success or failure string. [ "$exitCode" -eq 0 ] && exitCodeStr="succeeded" || exitCodeStr="failed" # Finally, we print the result string. echo "# 'python3 $2' $exitCodeStr with exit code $exitCode." |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |