From 6539f23f38689426ac419bde22fb7e69b22ae937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Thu, 11 Mar 2021 20:03:53 +0200 Subject: [PATCH] feat(__load_completion): don't hush errors or output when sourcing files We follow the message recent bash would output when sourcing a dir without letting bash to do it; doing so avoids fd leaks on some older but still supported bash versions. Other than that, let all output from sourcing the file pass through to ease debugging. Refs https://github.com/scop/bash-completion/issues/506 --- bash_completion | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bash_completion b/bash_completion index 8a88b3f0fe9..8accd9c6a76 100644 --- a/bash_completion +++ b/bash_completion @@ -2287,7 +2287,9 @@ __load_completion() for compfile in "$cmd" "$cmd.bash" "_$cmd"; do compfile="$dir/$compfile" # Avoid trying to source dirs; https://bugzilla.redhat.com/903540 - if [[ -f $compfile ]] && . "$compfile" &>/dev/null; then + if [[ -d $compfile ]]; then + echo "bash_completion: $compfile: is a directory" >&2 + elif [[ -e $compfile ]] && . "$compfile"; then [[ $backslash ]] && $(complete -p "$cmd") "\\$cmd" return 0 fi