dust
dust copied to clipboard
bash error in bash_completion.d/dust.bash after upgrade to v1.1.1
After upgrading to the latest version 1.1.1, I started getting the error from bash_completion/dust.bash:
-bash: /usr/local/etc/bash_completion.d/dust.bash: line 62: conditional binary operator expected
-bash: /usr/local/etc/bash_completion.d/dust.bash: line 62: syntax error near `IFS'
-bash: /usr/local/etc/bash_completion.d/dust.bash: line 62: ` if [[ -v IFS ]]; then'
I am on Mac OS 14.5 with GNU bash, version 5.2.32(1)-release (x86_64-apple-darwin23.4.0)
I also get the same result if I use the native Mac GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin23)
In looking for a solution I found this stack exchange post https://unix.stackexchange.com/questions/264926/is-it-a-sane-approach-to-back-up-the-ifs-variable
${IFS+"false"} && unset oldifs || oldifs="$IFS" # correctly store IFS.
IFS="error" ### change and use IFS as needed.
${oldifs+"false"} && unset IFS || IFS="$oldifs" # restore IFS.
So If I use this technique to save and restore IFS in the script, I don't see the error.
Here is the new code with the old code commented out.
--ignore-all-in-file)
${IFS+"false"} && unset oldifs || oldifs="$IFS"
# local oldifs
# if [[ -v IFS ]]; then
# oldifs="$IFS"
# fi
IFS=$'\n'
COMPREPLY=($(compgen -f "${cur}"))
${oldifs+"false"} && unset IFS || IFS="$oldifs"
# if [[ -v oldifs ]]; then
# IFS="$oldifs"
# fi
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o filenames
fi
return 0
;;
-I)
${IFS+"false"} && unset oldifs || oldifs="$IFS"
# local oldifs
# if [[ -v IFS ]]; then
# oldifs="$IFS"
# fi
IFS=$'\n'
COMPREPLY=($(compgen -f "${cur}"))
${oldifs+"false"} && unset IFS || IFS="$oldifs"
# if [[ -v oldifs ]]; then
# IFS="$oldifs"
# fi
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o filenames
fi
return 0
;;