earlyexit helper function
✓ Published0🌍 Public
Aalexfinnarn
Last edited Aug 21, 2018
Created on Aug 21, 2018
This example presents a shell function named `earlyexit` that checks the exit code of the previous command and halts script execution if a failure occurred. The function captures the status via the `$?` variable, compares it against zero, and prints a diagnostic message before exiting with status 1 on error; otherwise, it reports success. It demonstrates a simple control-flow pattern for robust Bash scripting, relying on standard shell built-ins and the `echo` command for output.
AI-generated description