Skip to content

Commit 7e8005d

Browse files
committed
Fix shellcheck warnings and errors
1 parent f717518 commit 7e8005d

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

.shellcheckrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Ignore unreachable code chunks (_filedir_original)
2+
disable=SC2317

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ test: deps venv
1212

1313

1414
lint:
15-
shellcheck --version
16-
shellcheck bash_completion
15+
@shellcheck --version
16+
shellcheck --color=always bash_completion
1717

1818

1919
clean: clean-venv

bash_completion

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ _bcpp_sed_detect() {
5454
_bcpp_put_wildcards() {
5555
local PROCESSED TILDE_EXPANSION INPUT
5656

57-
INPUT="$@"
57+
INPUT="$*"
5858
PROCESSED=$( \
5959
echo "$INPUT" | \
6060
$_BCPP_SED \
@@ -203,7 +203,7 @@ _bcpp() {
203203
DEFAULT="--files --dirs --cooperate --nocase --readline"
204204
ALL="--files --dirs --cooperate --nocase --readline"
205205
USAGE=(
206-
"Usage: $FUNCNAME OPTIONS"
206+
"Usage: ${FUNCNAME[0]} OPTIONS"
207207
" Manage enhanced path completion in bash"
208208
""
209209
"Options:"
@@ -253,8 +253,10 @@ _bcpp() {
253253
do
254254
case "$ARG" in
255255
--defaults)
256+
# shellcheck disable=SC2086
256257
set -- "$@" $DEFAULT ;;
257258
--all)
259+
# shellcheck disable=SC2086
258260
set -- "$@" $ALL ;;
259261
esac
260262
done
@@ -292,16 +294,16 @@ _bcpp() {
292294
done
293295

294296
# Special cases that terminate function
295-
if [[ "$KEYS" == *H* || -z "$@" ]] # --help|--usage|-h
297+
if [[ "$KEYS" == *H* || -z "$*" ]] # --help|--usage|-h
296298
then
297299
printf "%s\n" "${USAGE[@]}"
298300
return 0
299301
fi
300302
if [[ "$KEYS" == *U* ]] # unknown arguments
301303
then
302304
echo -e \
303-
"Unknown arguments: ${UNKNOWN[@]}" \
304-
"\nRefer to \`$FUNCNAME --help\` for more information" \
305+
"Unknown arguments: ${UNKNOWN[*]}" \
306+
"\nRefer to \`${FUNCNAME[0]} --help\` for more information" \
305307
>&2
306308
return 1
307309
fi
@@ -315,7 +317,7 @@ _bcpp() {
315317

316318
local _bcpp_filedir_original_code
317319
_bcpp_filedir_original_code=$(declare -f _filedir|tail -n+2)
318-
if [[ ! -z "$_bcpp_filedir_original_code" ]]
320+
if [[ -n "$_bcpp_filedir_original_code" ]]
319321
then
320322
type _bcpp_filedir_original &>/dev/null || \
321323
eval "_bcpp_filedir_original() $_bcpp_filedir_original_code"
@@ -327,7 +329,7 @@ _bcpp() {
327329

328330
local _bcpp_filedir_xspec_original_code
329331
_bcpp_filedir_xspec_original_code=$(declare -f _filedir_xspec|tail -n+2)
330-
if [[ ! -z "$_bcpp_filedir_xspec_original_code" ]]
332+
if [[ -n "$_bcpp_filedir_xspec_original_code" ]]
331333
then
332334
type _bcpp_filedir_xspec_original &>/dev/null || \
333335
eval "_bcpp_filedir_xspec_original() $_bcpp_filedir_xspec_original_code"

0 commit comments

Comments
 (0)