Skip to content

Commit 82cc37d

Browse files
author
Pierre Ayoub
authored
fix(git-bulk): fix a bad integer expression (#1198)
Fix a logic error inside the `allowedargcount()` function. This function may be called with one or two arguments. However, no default values are assigned to `$1` and `$2` that are used inside a numerical comparison. Therefore, when using a bad number of arguments for the following lines: ``` listall|purge) allowedargcount 1;; addcurrent|removeworkspace) allowedargcount 2;; ``` Then, we would get the error `[: : integer expression expected`. To fix this, we assign the 0 default value to `$1` and `$2`, such that we trigger the error message destined to the user without any integer error when there is a bad number of argument and that the function is called with only 1 argument instead of 2.
1 parent df53711 commit 82cc37d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

bin/git-bulk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function wsnameToCurrent () {
129129

130130
# helper to check number of arguments.
131131
function allowedargcount () {
132-
if [ "$paramcount" -ne "$1" ] && [ "$paramcount" -ne "$2" ]; then
132+
if [ "$paramcount" -ne "${1:-0}" ] && [ "$paramcount" -ne "${2:-0}" ]; then
133133
echo 1>&2 "error: wrong number of arguments" && usage;
134134
exit 1;
135135
fi

0 commit comments

Comments
 (0)