Skip to content

Instantly share code, notes, and snippets.

@Ara4Sh
Last active May 20, 2024 14:56
Show Gist options
  • Save Ara4Sh/7a5d96cfcddb557d430e17dca18e55ab to your computer and use it in GitHub Desktop.
Save Ara4Sh/7a5d96cfcddb557d430e17dca18e55ab to your computer and use it in GitHub Desktop.
Executing bash script commands in a subshell to manage status code and output
run() {
{ error=$($@ 2>&1 1>&$out); } {out}>&1
local status=$?
if [ $status -ne 0 ]; then
log $error
messages+="$error\n"
failed=true
echo "$messages"
exit 1
fi
return $status
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment