mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
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.
This commit is contained in:
parent
df53711fc7
commit
82cc37d0f5
|
|
@ -129,7 +129,7 @@ function wsnameToCurrent () {
|
|||
|
||||
# helper to check number of arguments.
|
||||
function allowedargcount () {
|
||||
if [ "$paramcount" -ne "$1" ] && [ "$paramcount" -ne "$2" ]; then
|
||||
if [ "$paramcount" -ne "${1:-0}" ] && [ "$paramcount" -ne "${2:-0}" ]; then
|
||||
echo 1>&2 "error: wrong number of arguments" && usage;
|
||||
exit 1;
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in a new issue