mirror of
https://github.com/kvz/bash3boilerplate.git
synced 2025-06-17 21:58:08 +00:00
* 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:
committed by
Kevin van Zonneveld
parent
2048e4303e
commit
ba0e7150cb
@ -18,16 +18,16 @@ addons:
|
|||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- debian-sid
|
- debian-sid
|
||||||
packages:
|
|
||||||
- shellcheck
|
|
||||||
install:
|
install:
|
||||||
- npm install
|
- npm install
|
||||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then npm run install:lanyon; fi
|
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then npm run install:lanyon; fi
|
||||||
before_install:
|
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 brew update; fi
|
||||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then which gsed || brew install gnu-sed; 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;
|
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then which gtimeout || brew install coreutils; fi
|
||||||
fi
|
|
||||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then which bundle || gem install bundler; fi
|
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then which bundle || gem install bundler; fi
|
||||||
- bash --version
|
- bash --version
|
||||||
- awk --version
|
- awk --version
|
||||||
|
6
main.sh
6
main.sh
@ -247,9 +247,11 @@ if [[ "${__b3bp_tmp_opts:-}" ]]; then
|
|||||||
printf -v "__b3bp_tmp_opt" '%s' "${!__b3bp_tmp_varname}"
|
printf -v "__b3bp_tmp_opt" '%s' "${!__b3bp_tmp_varname}"
|
||||||
# Only assign OPTARG if option takes an argument
|
# Only assign OPTARG if option takes an argument
|
||||||
__b3bp_tmp_varname="__b3bp_tmp_has_arg_${__b3bp_tmp_opt}"
|
__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
|
# shift over the argument if argument is expected
|
||||||
((OPTIND+=__b3bp_tmp_has_arg_${__b3bp_tmp_opt}))
|
((OPTIND+=__b3bp_tmp_varvalue))
|
||||||
fi
|
fi
|
||||||
# we have set opt/OPTARG to the short value and the argument as OPTARG if it exists
|
# we have set opt/OPTARG to the short value and the argument as OPTARG if it exists
|
||||||
fi
|
fi
|
||||||
|
@ -59,7 +59,7 @@ if [[ ! "$(command -v ${cmdTimeout})" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
__node="$(which node)"
|
__node="$(command -v node)"
|
||||||
__arch="amd64"
|
__arch="amd64"
|
||||||
|
|
||||||
# explicitly setting NO_COLOR to false will make b3bp ignore TERM
|
# 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
|
# 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
|
while IFS=$'\n' read -r bash; do
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
echo "==> ${bash} -n $(${bash} -c 'echo "(${BASH_VERSION})"')"
|
echo "==> ${bash} -n $(${bash} -c 'echo "(${BASH_VERSION})"')"
|
||||||
|
@ -153,3 +153,17 @@ ACCPTST:STDIO_REPLACE_DATETIMES
|
|||||||
{datetime} UTC [ info] arg_b: do-b
|
{datetime} UTC [ info] arg_b: do-b
|
||||||
{datetime} UTC [ info] arg_c: do-c
|
{datetime} UTC [ info] arg_c: do-c
|
||||||
{datetime} UTC [ info] arg_d: argd
|
{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
|
||||||
|
@ -56,3 +56,9 @@ echo "# complain about nothing"
|
|||||||
source "${__root}/main.sh" -3 arg3 -4 arg4 -5 arg5 -8 arg8 -d argd
|
source "${__root}/main.sh" -3 arg3 -4 arg4 -5 arg5 -8 arg8 -d argd
|
||||||
for argument in ${!arg_*}; do info "${argument}: ${!argument}"; done
|
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
|
||||||
|
)
|
||||||
|
Reference in New Issue
Block a user