Fix or silence remaining warnings with shellcheck v0.7.0 (#117)

SC2235: The warning/suggestion about the subshell was letigimate, so
the suggested fix is implemented.

SC2034: The variable __invocation is indeed unused, but it's supposed
to be there in case the script using bash3boilerplate wants to use it,
so this commit silences the warning.

SC1102: The warning about the parsing of $((( is legitimate, so the
suggested fix is implemented.

SC2015: While the warning is correct in general, here 'true' has no
side effects hence it can be silenced.

Fixes #107.
This commit is contained in:
Lukas Stockner 2019-09-20 11:30:59 +02:00 committed by Kevin van Zonneveld
parent 7b7d31a1bf
commit 664e55ad1e
3 changed files with 6 additions and 2 deletions

View File

@ -21,6 +21,7 @@ Released: TBA.
- [x] Fix typo in FAQ (#92, @gmasse) - [x] Fix typo in FAQ (#92, @gmasse)
- [x] Fix Travis CI failure on src/templater.sh (@gmasse) - [x] Fix Travis CI failure on src/templater.sh (@gmasse)
- [x] Add magic variable which contains full command invocation - [x] Add magic variable which contains full command invocation
- [x] Fix remaining warnings with shellcheck v0.7.0 (#107, @genesiscloud)
## v2.3.0 ## v2.3.0

View File

@ -146,6 +146,7 @@ $ my_script some more args --blah
- [OpenCoarrays](http://www.opencoarrays.org) - [OpenCoarrays](http://www.opencoarrays.org)
- [Sourcery Institute](http://www.sourceryinstitute.org) - [Sourcery Institute](http://www.sourceryinstitute.org)
- [Computational Brain Anatomy Laboratory](http://cobralab.ca/) - [Computational Brain Anatomy Laboratory](http://cobralab.ca/)
- [Genesis Cloud](https://genesiscloud.com/)
We are looking for endorsements! Are you also using b3bp? [Let us know](https://github.com/kvz/bash3boilerplate/issues/new?title=I%20use%20b3bp) and get listed. We are looking for endorsements! Are you also using b3bp? [Let us know](https://github.com/kvz/bash3boilerplate/issues/new?title=I%20use%20b3bp) and get listed.
@ -165,6 +166,7 @@ We are looking for endorsements! Are you also using b3bp? [Let us know](https://
- [Giovanni Saponaro](https://github.com/gsaponaro) (feedback) - [Giovanni Saponaro](https://github.com/gsaponaro) (feedback)
- [Germain Masse](https://github.com/gmasse) - [Germain Masse](https://github.com/gmasse)
- [A. G. Madi](https://github.com/warpengineer) - [A. G. Madi](https://github.com/warpengineer)
- [Lukas Stockner](mailto:oss@genesiscloud.com)
## License ## License

View File

@ -47,7 +47,8 @@ fi
__dir="$(cd "$(dirname "${BASH_SOURCE[${__b3bp_tmp_source_idx:-0}]}")" && pwd)" __dir="$(cd "$(dirname "${BASH_SOURCE[${__b3bp_tmp_source_idx:-0}]}")" && pwd)"
__file="${__dir}/$(basename "${BASH_SOURCE[${__b3bp_tmp_source_idx:-0}]}")" __file="${__dir}/$(basename "${BASH_SOURCE[${__b3bp_tmp_source_idx:-0}]}")"
__base="$(basename "${__file}" .sh)" __base="$(basename "${__file}" .sh)"
__invocation="$(printf %q "${__file}")$((($#)) && printf ' %q' "$@" || true)" # shellcheck disable=SC2034,SC2015
__invocation="$(printf %q "${__file}")$( (($#)) && printf ' %q' "$@" || true)"
# Define the environment variables (and their defaults) that this script depends on # Define the environment variables (and their defaults) that this script depends on
LOG_LEVEL="${LOG_LEVEL:-6}" # 7 = debug -> 0 = emergency LOG_LEVEL="${LOG_LEVEL:-6}" # 7 = debug -> 0 = emergency
@ -83,7 +84,7 @@ function __b3bp_log () {
local color="${!colorvar:-${color_error}}" local color="${!colorvar:-${color_error}}"
local color_reset="\\x1b[0m" local color_reset="\\x1b[0m"
if [[ "${NO_COLOR:-}" = "true" ]] || ( [[ "${TERM:-}" != "xterm"* ]] && [[ "${TERM:-}" != "screen"* ]] ) || [[ ! -t 2 ]]; then if [[ "${NO_COLOR:-}" = "true" ]] || { [[ "${TERM:-}" != "xterm"* ]] && [[ "${TERM:-}" != "screen"* ]]; } || [[ ! -t 2 ]]; then
if [[ "${NO_COLOR:-}" != "false" ]]; then if [[ "${NO_COLOR:-}" != "false" ]]; then
# Don't use colors on pipes or non-recognized terminals # Don't use colors on pipes or non-recognized terminals
color=""; color_reset="" color=""; color_reset=""