File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+
4+ #
5+ # NAVIGATE TO CORRECT DIRECTORY
6+ #
7+
8+ # start by going to script dir so all movements
9+ # from here are relative
10+ SCRIPT_DIR=` dirname $( realpath " $0 " ) `
11+ cd $SCRIPT_DIR
12+
13+
14+ #
15+ # PARSE & RUN COMMANDS
16+ #
17+
18+ # check if expansion of $1 is null
19+ # from: https://stackoverflow.com/a/6482403
20+ if [ -z $1 ]; then
21+ echo ' A command must be given.'
22+ exit 1
23+ fi
24+
25+ function run {
26+ $1 ${@: 2}
27+
28+ exit $?
29+ }
30+
31+ # first check hard-coded shortcuts
32+ if [[ $1 = " t" ]]; then
33+ run ./test ${@: 2}
34+ fi
35+ if [[ $1 = " d" ]]; then
36+ run ./dev ${@: 2}
37+ fi
38+
39+ # otherwise, search for exact match to script name
40+ for file in ./* ; do
41+ file_name=${file# " ./" }
42+
43+ if [[ $file_name = $1 ]]; then
44+ run $file ${@: 2}
45+ fi
46+ done
You can’t perform that action at this time.
0 commit comments