Skip to content

Instantly share code, notes, and snippets.

@denisolvr
Created March 12, 2021 13:58
Show Gist options
  • Select an option

  • Save denisolvr/f2e465250e6d5791cc174f5ba2de7d97 to your computer and use it in GitHub Desktop.

Select an option

Save denisolvr/f2e465250e6d5791cc174f5ba2de7d97 to your computer and use it in GitHub Desktop.
Shell Script Wrapper function
#! /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