Created
October 27, 2017 21:44
-
-
Save tonyskapunk/c31cdcc2aba3ebc81ec5cc8711e7cb3c to your computer and use it in GitHub Desktop.
multiple args
This file contains 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
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