bugfix: compress aliases for first command in completion (#40890)

This completes to `spack concretize`:

```
spack conc<tab>
```

but this still gets hung up on the difference between `concretize` and `concretise`:

```
spack -e . conc<tab>
```

We were checking `"$COMP_CWORD" = 1`, which tracks the word on the command line
including any flags and their args, but we should track `"$COMP_CWORD_NO_FLAGS" = 1` to
figure out if the arg we're completing is the first real command.
This commit is contained in:
Todd Gamblin 2023-11-05 02:15:37 -08:00 committed by GitHub
parent 4755b28398
commit f6b23b4653
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -370,7 +370,7 @@ _spack_compress_aliases() {
# If there are zero or one completions, don't do anything
# If this isn't the first argument, bail because aliases currently only apply
# to top-level commands.
if [ "${#COMPREPLY[@]}" -le "1" ] || [ "$COMP_CWORD" != "1" ]; then
if [ "${#COMPREPLY[@]}" -le "1" ] || [ "$COMP_CWORD_NO_FLAGS" != "1" ]; then
return
fi

View file

@ -370,7 +370,7 @@ _spack_compress_aliases() {
# If there are zero or one completions, don't do anything
# If this isn't the first argument, bail because aliases currently only apply
# to top-level commands.
if [ "${#COMPREPLY[@]}" -le "1" ] || [ "$COMP_CWORD" != "1" ]; then
if [ "${#COMPREPLY[@]}" -le "1" ] || [ "$COMP_CWORD_NO_FLAGS" != "1" ]; then
return
fi