Gist e285625bdefd54393a281139a91f7596
✓ Published0🌍 Public
Aalexfinnarn
Last edited Aug 21, 2018
Created on Aug 21, 2018
This shell script example demonstrates an automated early-exit pattern for command-line workflows. It shows how to check the exit code of the previous command and halt execution if it failed, printing a failure message before exiting with status 1. The script defines a reusable `earlyexit` function that uses Bash’s `$?` variable to capture the last command’s return code, then conditionally triggers an exit. On success, it prints “Script succeeded.” The implementation relies purely on standard Bash syntax, with no external visualization or data-processing libraries.
AI-generated description