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

Update _completion_shared.py #728

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bufferbit
Copy link

Wrap quotes around completion_path variable to solve potential issues from whitespace in the path name. I encountered this issue when using the --install-completion flag on a local module:

$ python3 -m cli --install-completion

This would create the file ~/.bash_completions/python3 -m cli.sh and broke code that referenced the unquoted path in .bashrc.


Something additional I thought of but could not figure out how to implement was adding the following code to .bashrc:

if [ -d "${HOME}/.bash_completions" ]; then
    for file in $(realpath -- "${HOME}/.bash_completions/*.sh"); do
        if [ -f "$file" ]; then
            source "$file"
        fi
    done
fi

This also solves the whitespace issue, but additionally removes the need to append a new line to .bashrc every time the --install-completion flag is used.

Wrap quotes around `completion_path` variable to solve potential issues from whitespace in the path name. Eg. "~/.bash_completions/file name.sh"
@svlandeg svlandeg added feature New feature, enhancement or request p3 and removed feature New feature, enhancement or request labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature, enhancement or request p3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants