diff options
author | Harmen Stoppels <harmenstoppels@gmail.com> | 2022-01-06 14:47:03 +0100 |
---|---|---|
committer | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2022-04-14 11:08:17 +0200 |
commit | 69cbf10a804ad7dbf99d2fc08d2c20c7ba2ef7a2 (patch) | |
tree | a8c736ef03e039a41d3b9c6217909e29932c3a6f /share | |
parent | 5b2d7445b817844ccf44ec3e2a77c883cc5edb3e (diff) | |
download | spack-69cbf10a804ad7dbf99d2fc08d2c20c7ba2ef7a2.tar.gz spack-69cbf10a804ad7dbf99d2fc08d2c20c7ba2ef7a2.tar.bz2 spack-69cbf10a804ad7dbf99d2fc08d2c20c7ba2ef7a2.tar.xz spack-69cbf10a804ad7dbf99d2fc08d2c20c7ba2ef7a2.zip |
Fix spack install --v[tab] spec (#28278)
Diffstat (limited to 'share')
-rwxr-xr-x | share/spack/bash/spack-completion.in | 2 | ||||
-rwxr-xr-x | share/spack/qa/completion-test.sh | 10 | ||||
-rwxr-xr-x | share/spack/spack-completion.bash | 2 |
3 files changed, 12 insertions, 2 deletions
diff --git a/share/spack/bash/spack-completion.in b/share/spack/bash/spack-completion.in index 77cd16d076..8c01232f5e 100755 --- a/share/spack/bash/spack-completion.in +++ b/share/spack/bash/spack-completion.in @@ -123,7 +123,7 @@ _bash_completion_spack() { # If the cursor is in the middle of the line, like: # `spack -d [] install` # COMP_WORDS will not contain the empty character, so we have to add it. - if [[ "${COMP_LINE:$COMP_POINT:1}" == " " ]] + if [[ "${COMP_LINE:$COMP_POINT-1:1}" == " " ]] then cur="" fi diff --git a/share/spack/qa/completion-test.sh b/share/spack/qa/completion-test.sh index 0777002f0a..d56a8ba6ef 100755 --- a/share/spack/qa/completion-test.sh +++ b/share/spack/qa/completion-test.sh @@ -70,6 +70,16 @@ _test_debug_functions() { emulate -L sh fi + # Test whether `spack install --verb[] spec` completes to `spack install --verbose spec` + COMP_LINE='spack install --verb spec' + COMP_POINT=20 + COMP_WORDS=(spack install --verb spec) + COMP_CWORD=2 + COMP_KEY=9 + COMP_TYPE=64 + _bash_completion_spack + contains "--verbose" echo "${COMPREPLY[@]}" + # This is a particularly tricky case that involves the following situation: # `spack -d [] install ` # Here, [] represents the cursor, which is in the middle of the line. diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash index b41a21946c..e92a525e63 100755 --- a/share/spack/spack-completion.bash +++ b/share/spack/spack-completion.bash @@ -123,7 +123,7 @@ _bash_completion_spack() { # If the cursor is in the middle of the line, like: # `spack -d [] install` # COMP_WORDS will not contain the empty character, so we have to add it. - if [[ "${COMP_LINE:$COMP_POINT:1}" == " " ]] + if [[ "${COMP_LINE:$COMP_POINT-1:1}" == " " ]] then cur="" fi |