Skip to content

Instantly share code, notes, and snippets.

@tonyskapunk
Created October 27, 2017 21:44
Show Gist options
  • Save tonyskapunk/c31cdcc2aba3ebc81ec5cc8711e7cb3c to your computer and use it in GitHub Desktop.
Save tonyskapunk/c31cdcc2aba3ebc81ec5cc8711e7cb3c to your computer and use it in GitHub Desktop.
multiple args
eat() {
log=${1}; shift
cmd=${1}; shift
dop=( ${1} ); shift
opt=( ${1} ); shift
arg=${@}
echo "loging into ${log}"
echo "runing: ${cmd} ${opt[@]} ${arg[@]}"
${cmd} ${opt[@]} ${arg[@]}
echo "if it fails then"
echo "runing: ${cmd} ${dop[@]} ${arg[@]}"
${cmd} ${dop[@]} ${arg[@]}
}
echo example1 > example1
eat "sushi" cat "-A -e" "-t -u" $( basename ${0} ) example1
echo =======================================
echo example2 > example2
eat "sushi" cat "-n -s" "-u --this-is-wrong" $( basename ${0} ) example2
echo =======================================
echo example3 > example3
eat "sushi" cat "-A -e" "" $( basename ${0} ) example1
echo =======================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment