1
1
#! /usr/bin/env bash
2
2
3
- PACKCHECK_DIR=" $( dirname $0 ) "
3
+ PACKCHECK_DIR=$( dirname " $0 " )
4
4
PACKCHECK_EXE=" $PACKCHECK_DIR /packcheck.sh"
5
5
PWD=" $( pwd) "
6
6
DEFAULT_DIRECTORY_NAME=" packcheck-remote-work"
@@ -20,19 +20,21 @@ which_cmd() {
20
20
21
21
# $1: executable (eg. git)
22
22
require_cmd () {
23
- if test -z " $( which_cmd $1 ) "
23
+ local cmd_path
24
+ cmd_path=$( which_cmd " $1 " )
25
+ if test -z " $cmd_path "
24
26
then
25
27
echo " Required command [$1 ] not found in PATH [$PATH ]."
26
28
exit 1
27
29
else
28
- echo " Using [$1 ] at [$( which_cmd $1 ) ]"
30
+ echo " Using [$1 ] at [$cmd_path ]"
29
31
fi
30
32
}
31
33
32
34
# $1: command
33
35
function run_verbose() {
34
- echo " $* "
35
- bash -c " $* "
36
+ echo " $1 "
37
+ bash -c " $1 "
36
38
}
37
39
38
40
# $1: Remote repository
@@ -98,16 +100,13 @@ try_git_clone_and_merge() {
98
100
99
101
if test -n " $merge "
100
102
then
101
- # This will fail is there are any merge conflicts
103
+ # This will fail if there are any merge conflicts
102
104
run_verbose " git merge -X theirs $merge --no-edit --commit" || exit 1
103
105
fi
104
106
105
107
show_step " Running packcheck"
106
108
# Run packcheck here
107
109
run_verbose " $PACKCHECK_EXE $packcheck_cli_opts "
108
-
109
- # Go back to where the script was executed from
110
- cd " $PWD " || exit 1
111
110
}
112
111
113
112
# Arguments for the command line
@@ -116,10 +115,12 @@ REMOTE=""
116
115
CHECKOUT=" "
117
116
MERGE=" "
118
117
DIRECTORY=" "
118
+ PACKCHECK_CLI_OPTS_ARR=()
119
119
PACKCHECK_CLI_OPTS=" "
120
120
121
121
function run_help() {
122
- local script=$( basename $0 )
122
+ local script
123
+ script=$( basename " $0 " )
123
124
124
125
echo
125
126
echo " USAGE: --option[=value]"
177
178
;;
178
179
--)
179
180
shift
180
- PACKCHECK_CLI_OPTS= $@
181
+ PACKCHECK_CLI_OPTS_ARR=( " $@ " )
181
182
break
182
183
;;
183
184
* )
188
189
esac
189
190
done
190
191
192
+ for i in " ${PACKCHECK_CLI_OPTS_ARR[@]} "
193
+ do
194
+ case $i in
195
+ * =* )
196
+ key=${1%% =* }
197
+ val=${1#* =}
198
+ PACKCHECK_CLI_OPTS=" $PACKCHECK_CLI_OPTS $key =\" $val \" "
199
+ shift
200
+ ;;
201
+ * )
202
+ PACKCHECK_CLI_OPTS=" $PACKCHECK_CLI_OPTS $i "
203
+ shift
204
+ ;;
205
+ esac
206
+ done
207
+
191
208
try_git_clone_and_merge " $REMOTE " " $CHECKOUT " " $MERGE " " $DIRECTORY " " $FORCE " " $PACKCHECK_CLI_OPTS "
0 commit comments