Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error occurred when completing the "umount" command #1260

Open
YoruStar opened this issue Nov 7, 2024 · 0 comments · May be fixed by #1290
Open

Error occurred when completing the "umount" command #1260

YoruStar opened this issue Nov 7, 2024 · 0 comments · May be fixed by #1290

Comments

@YoruStar
Copy link

YoruStar commented Nov 7, 2024

Describe the bug

When completing the umount o command, the following error occurred:

[root@localhost ~]# umount obash_completion: _comp_compgen: -C: invalid directory name `'
verlay

To reproduce

The problematic version is bash-completion-2.12

$ mkdir overlay
$ mount -t tmpfs tmpfs overlay/
$ umount o[TAB]bash_completion: _comp_compgen: -C: invalid directory name `'
verlay

Expected behavior

$ mkdir overlay
$ mount -t tmpfs tmpfs overlay/
$ umount o[TAB]verlay

Versions (please complete the following information)

$ echo "$BASH_VERSION"
5.2.15(1)-release
$ IFS=.; echo "${BASH_COMPLETION_VERSINFO[*]}"
2.12.0

Additional context

The issue was introduced after feat(_comp_compgen): support option -C

Debug trace

# Add relative paths to COMPREPLY
if [[ $cur && $cur != /* ]]; then
    local realcur
    [[ $cur == */ ]] && # don't let readlink drop last / from path
        realcur="$(readlink -f "$cur." 2>/dev/null)/" ||
        realcur=$(readlink -f "$cur" 2>/dev/null)
    if [[ $realcur ]]; then
        local dirrealcur="" dircur="" basecur
        if [[ $cur == */* ]]; then
            dirrealcur="${realcur%/*}/"
            dircur="${cur%/*}/"
        fi
        basecur=${cur#"$dircur"}
        local i
        for i in ${!COMPREPLY[*]}; do
            [[ ${COMPREPLY[i]} == "$realcur"* ]] &&
                _comp_compgen -aC "$dircur" -c "$basecur" -- \
                    -f -d -P "$dircur" -X "!${COMPREPLY[i]##"$dirrealcur"}"
        done
    fi
fi

In the above code, when executing the _comp_compgen -aC '$dircur' -c '$basecur' command, the value of the dircur variable is empty. This causes _comp_compgen to consider it an invalid argument, resulting in an error.

C)
    if [[ ! $OPTARG ]]; then
        printf 'bash_completion: %s: -C: invalid directory name `%s'\''\n' "$FUNCNAME" "$OPTARG" >&2
        return 2
    fi
    _dir=$OPTARG
    ;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant