Skip to content

bash error in bash_completion.d/dust.bash after upgrade to v1.1.1 #426

Open
@jeffbski-rga

Description

@jeffbski-rga

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
                    ;;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions