Skip to content

Instantly share code, notes, and snippets.

@nhatzHK
Created June 8, 2017 23:56
Show Gist options
  • Save nhatzHK/d68c6b62632ca3d81c7a3fbcbac05521 to your computer and use it in GitHub Desktop.
Save nhatzHK/d68c6b62632ca3d81c7a3fbcbac05521 to your computer and use it in GitHub Desktop.
I was dumb enough to not modify path
#!/usr/bin/sh
# Execute the script specified as argument
# Directory where the script are stored
baseDir=/opt/nhatz_bash
passed_args=("$@") #list of provided arguments stored in new array
comm=$1 #script/command to call, first on the list
comm_pos=0 #position of $comm in the array
new_args=(${passed_args[@]:0:$comm_pos} ${passed_args[@]:$(($comm_pos + 1 ))}) #list of arguments without $comm
if [ -d $baseDir/$comm ]; then
$baseDir/$comm/$comm.sh $(echo ${new_args[@]})
else
echo "[Nhatz] Unknown commad: $comm"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment