From f6b23b4653c73f60e826086154cad3040c1b61a7 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Sun, 5 Nov 2023 02:15:37 -0800 Subject: bugfix: compress aliases for first command in completion (#40890) This completes to `spack concretize`: ``` spack conc ``` but this still gets hung up on the difference between `concretize` and `concretise`: ``` spack -e . conc ``` 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. --- share/spack/bash/spack-completion.bash | 2 +- share/spack/spack-completion.bash | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/spack/bash/spack-completion.bash b/share/spack/bash/spack-completion.bash index 49c691be4c..9a5b367be7 100755 --- a/share/spack/bash/spack-completion.bash +++ b/share/spack/bash/spack-completion.bash @@ -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 diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash index 84b6c3dc1f..91ed9dd172 100755 --- a/share/spack/spack-completion.bash +++ b/share/spack/spack-completion.bash @@ -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 -- cgit v1.2.3-70-g09d2