Repository navigation
completion/aliases: pass the last alias word as the preceding word - #2419
Merged
Merged
Conversation
The wrapper stripped only the command from 'cmd args', so $3 held all alias
arguments ('config use-context') instead of the last word ('use-context').
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ash 3.2 The init callback ends a 'read -d ""' at EOF (status 1), which bash 3.2 propagates through bats' errexit when load is called directly. Other tests in the file avoid this by using 'run'; this one needs the wrapper defined in the current shell, so disable errexit around load and assert the wrapper exists. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
For an alias such as
alias kubectx='kubectl config use-context', the generated completion wrapper set the preceding word ($3) toconfig use-contextinstead of the last alias word,use-context. The wrapper stripped only the command fromcmd args.Completion functions that read
$3rather than calling_get_comp_words_by_ref(cobra-generated scripts do the latter) received the wrong value. The wrapper now passes the last alias word, quoted withprintf %qat generation time like the other embedded values.Motivation and Context
Found while investigating #2264. This does not fix that issue. I could not reproduce it on current
master: with realkubectlv1.37.1,kubectx mi<TAB>andkubectx k3s-<TAB>complete correctly with and without this change (bash 5.1.16,systemandaliasescompletions enabled,source <(kubectl completion bash)before bash-it). This is a separate, small correction.How Has This Been Tested?
$1,$2,$3,COMP_LINE,COMP_WORDSandCOMP_CWORD. It fails before the change and passes after.test/run test/completion/aliases.completion.bats: 4/4 pass.Types of changes
🤖 Generated with Claude Code