Skip to content

cd completion gives dir and dir/ when CDPATH is set #1545

Description

@jmou

Describe the bug

This bug seems to require a few things to occur:

  • CDPATH must be set
  • The parameter being completed must be the full name of a directory in the current directory
  • No other directory is a valid completion

To reproduce

$ CDPATH=.
$ cd /
$ cd usr[TAB][TAB]
usr/  usr// 

Expected behavior

Should have completed to cd bin/

Versions (please complete the following information)

  • Operating system name/distribution and version: Fedora 43
  • bash version, echo "$BASH_VERSION": 5.3.0(1)-release
  • bash-completion version, (IFS=.; echo "${BASH_COMPLETION_VERSINFO[*]}"): git commit ed0ae10 and later

Additional context

This bug is in git but not in the distribution package. It appears to be a regression from commit ed0ae10 (the bug does not occur in its parent).

Commenting out this section appears to make the issue go away (although I don't understand what it is for):

    if ((${#_cdpaths[@]} == 1)); then
        _p=${_cdpaths[0]}
        if [[ $_p == "$cur" && $_p != */ ]]; then
            _cdpaths[0]=$_p/
        fi
    fi

Debug trace

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