close issue #108 (#109)

* added test for issue-108

* Closes #108

* fixed some easy shellcheck complaints

* trying to fix travis/debian-sid/shellcheck problem
This commit is contained in:
Manuel Streuhofer 2018-09-03 12:00:55 +02:00 committed by Kevin van Zonneveld
parent 2048e4303e
commit ba0e7150cb
5 changed files with 31 additions and 7 deletions

View File

@ -18,16 +18,16 @@ addons:
apt:
sources:
- debian-sid
packages:
- shellcheck
install:
- npm install
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then npm run install:lanyon; fi
before_install:
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install -y cabal-install; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then cabal update; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then cabal install shellcheck; fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then which gsed || brew install gnu-sed; fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then which gtimeout || brew install coreutils;
fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then which gtimeout || brew install coreutils; fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then which bundle || gem install bundler; fi
- bash --version
- awk --version

View File

@ -247,9 +247,11 @@ if [[ "${__b3bp_tmp_opts:-}" ]]; then
printf -v "__b3bp_tmp_opt" '%s' "${!__b3bp_tmp_varname}"
# Only assign OPTARG if option takes an argument
__b3bp_tmp_varname="__b3bp_tmp_has_arg_${__b3bp_tmp_opt}"
printf -v "OPTARG" '%s' "${@:OPTIND:${!__b3bp_tmp_varname}}"
__b3bp_tmp_varvalue="${!__b3bp_tmp_varname}"
[[ "${__b3bp_tmp_varvalue}" != "0" ]] && __b3bp_tmp_varvalue="1"
printf -v "OPTARG" '%s' "${@:OPTIND:${__b3bp_tmp_varvalue}}"
# shift over the argument if argument is expected
((OPTIND+=__b3bp_tmp_has_arg_${__b3bp_tmp_opt}))
((OPTIND+=__b3bp_tmp_varvalue))
fi
# we have set opt/OPTARG to the short value and the argument as OPTARG if it exists
fi

View File

@ -59,7 +59,7 @@ if [[ ! "$(command -v ${cmdTimeout})" ]]; then
exit 1
fi
__node="$(which node)"
__node="$(command -v node)"
__arch="amd64"
# explicitly setting NO_COLOR to false will make b3bp ignore TERM
@ -195,6 +195,8 @@ done <<< "$(find "${__dir}/scenario" -type f -iname 'run.sh')"
# Ensure correct syntax with all available bashes
# shellcheck disable=SC2230
# "command -v" is not a substitute for "which -a"
while IFS=$'\n' read -r bash; do
# shellcheck disable=SC2016
echo "==> ${bash} -n $(${bash} -c 'echo "(${BASH_VERSION})"')"

View File

@ -153,3 +153,17 @@ ACCPTST:STDIO_REPLACE_DATETIMES
{datetime} UTC [ info] arg_b: do-b
{datetime} UTC [ info] arg_c: do-c
{datetime} UTC [ info] arg_d: argd
# test for issue #108
{datetime} UTC [ info] arg_0: 1
{datetime} UTC [ info] arg_1: 0
{datetime} UTC [ info] arg_2: 0
{datetime} UTC [ info] arg_3: arg3
{datetime} UTC [ info] arg_4: value
{datetime} UTC [ info] arg_5: arg5
{datetime} UTC [ info] arg_6:
{datetime} UTC [ info] arg_7:
{datetime} UTC [ info] arg_8: arg8
{datetime} UTC [ info] arg_a: do-a
{datetime} UTC [ info] arg_b: do-b
{datetime} UTC [ info] arg_c: do-c
{datetime} UTC [ info] arg_d: argd

View File

@ -56,3 +56,9 @@ echo "# complain about nothing"
source "${__root}/main.sh" -3 arg3 -4 arg4 -5 arg5 -8 arg8 -d argd
for argument in ${!arg_*}; do info "${argument}: ${!argument}"; done
)
echo "# test for issue #108"
(
source "${__root}/main.sh" -3 arg3 -5 arg5 -8 arg8 -d argd --four value --zero
for argument in ${!arg_*}; do info "${argument}: ${!argument}"; done
)