From f911c0b89c6e0c41b6ad218c9235d8706c36a1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 14 Aug 2022 00:44:47 +0300 Subject: [PATCH] fix(bash-v2): activeHelp length check syntax (#1762) ```shell $ set -u $ foo=() $ echo ${#foo} bash: foo: unbound variable echo ${#foo[*]} 0 ``` The above shows that an empty array needs the suffix `[*]` when checking its length, or else it is considered unbound. --- bash_completionsV2.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash_completionsV2.go b/bash_completionsV2.go index 767bf03..351391a 100644 --- a/bash_completionsV2.go +++ b/bash_completionsV2.go @@ -150,7 +150,7 @@ __%[1]s_process_completion_results() { __%[1]s_handle_special_char "$cur" = # Print the activeHelp statements before we finish - if [ ${#activeHelp} -ne 0 ]; then + if [ ${#activeHelp[*]} -ne 0 ]; then printf "\n"; printf "%%s\n" "${activeHelp[@]}" printf "\n"