Skip to content

Instantly share code, notes, and snippets.

@MarshalW
Created July 21, 2014 13:57
Show Gist options
  • Save MarshalW/2e390350ce37cf1407a0 to your computer and use it in GitHub Desktop.
Save MarshalW/2e390350ce37cf1407a0 to your computer and use it in GitHub Desktop.
save run command
#!/bin/bash
safeRunCommand() {
typeset cmnd="$*"
typeset ret_code
echo cmnd=$cmnd
eval $cmnd
ret_code=$?
if [ $ret_code != 0 ]; then
printf "Error : [%d] when executing command: '$cmnd'" $ret_code
exit $ret_code
fi
}
command='uname ''"'$1'"'
safeRunCommand "$command"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment