Created
March 12, 2021 13:58
-
-
Save denisolvr/f2e465250e6d5791cc174f5ba2de7d97 to your computer and use it in GitHub Desktop.
Shell Script Wrapper function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/bash | |
| do_cmd() | |
| { | |
| tstart=`date '+%D %X'` | |
| printf "%s\t%s\n" "$tstart" "Starting command[ $@ ]" | |
| time "$@" | |
| ret=$? | |
| if [[ $ret -eq 0 ]] | |
| then | |
| echo "Successfully ran [ $@ ]" | |
| else | |
| echo "Error: Command [ $@ ] returned $ret" | |
| exit $ret | |
| fi | |
| } | |
| export -f do_cmd | |
| # do_cmd [COMAND] | |
| do_cmd ls -la |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment