summaryrefslogtreecommitdiff
path: root/etc/completion/bash
diff options
context:
space:
mode:
authorTobias Geerinckx-Rice <me@tobias.gr>2022-05-22 02:00:00 +0200
committerTobias Geerinckx-Rice <me@tobias.gr>2022-05-29 02:00:20 +0200
commitdc6d92ac93cedd65f6c99daa530b69f43f6039ec (patch)
treeb56ec8ebc679fbb2e5653f711448801eeef99543 /etc/completion/bash
parent4cb6994790d1b499bc07f183ac9d7b4fbfc3c9bc (diff)
bash completion: Fix & unify option parsing.
We now correctly recognise ‘guix -Abcdef’ as equivalent to ‘guix -f’. * etc/completion/bash/guix (_guix_is_short_option, guix_is_long_option): New functions. (_guix_is_dash_f, _guix_is_dash_l, _guix_is_dash_L, _guix_is_dash_m) (_guix_is_dash_C, _guix_is_dash_p): Use them.
Diffstat (limited to 'etc/completion/bash')
-rw-r--r--etc/completion/bash/guix61
1 files changed, 31 insertions, 30 deletions
diff --git a/etc/completion/bash/guix b/etc/completion/bash/guix
index 6b1b70aac1d..7b1f639371f 100644
--- a/etc/completion/bash/guix
+++ b/etc/completion/bash/guix
@@ -117,58 +117,59 @@ _guix_is_removing ()
117 $result 117 $result
118} 118}
119 119
120_guix_is_short_option ()
121{
122 case "${COMP_WORDS[$COMP_CWORD - 1]}" in
123 --*) false;;
124 -*$1) true ;;
125 *) false ;;
126 esac
127}
128
129_guix_is_long_option ()
130{
131 # Don't handle (non-GNU?) ‘--long-option VALUE’, as Guix doesn't either.
132 case "${COMP_WORDS[$COMP_CWORD]}" in
133 --$1=*) true ;;
134 *) false ;;
135 esac
136}
137
120_guix_is_dash_f () 138_guix_is_dash_f ()
121{ 139{
122 [ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-f" ] \ 140 _guix_is_short_option f ||
123 || { case "${COMP_WORDS[$COMP_CWORD]}" in 141 _guix_is_long_option file ||
124 --file=*|--install-from-file=*) true;; 142 _guix_is_long_option install-from-file
125 *) false;;
126 esac }
127} 143}
128 144
129_guix_is_dash_l () 145_guix_is_dash_l ()
130{ 146{
131 [ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-l" ] \ 147 _guix_is_short_option l ||
132 || { case "${COMP_WORDS[$COMP_CWORD]}" in 148 _guix_is_long_option load
133 --load=*) true;;
134 *) false;;
135 esac }
136} 149}
137 150
138_guix_is_dash_L () 151_guix_is_dash_L ()
139{ 152{
140 [ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-L" ] \ 153 _guix_is_short_option L ||
141 || { case "${COMP_WORDS[$COMP_CWORD]}" in 154 _guix_is_long_option load-path
142 --load-path=*) true;;
143 *) false;;
144 esac }
145} 155}
146 156
147_guix_is_dash_m () 157_guix_is_dash_m ()
148{ 158{
149 [ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-m" ] \ 159 _guix_is_short_option m ||
150 || { case "${COMP_WORDS[$COMP_CWORD]}" in 160 _guix_is_long_option manifest
151 --manifest=*) true;;
152 *) false;;
153 esac }
154} 161}
155 162
156_guix_is_dash_C () 163_guix_is_dash_C ()
157{ 164{
158 [ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-C" ] \ 165 _guix_is_short_option C ||
159 || { case "${COMP_WORDS[$COMP_CWORD]}" in 166 _guix_is_long_option channels
160 --channels=*) true;;
161 *) false;;
162 esac }
163} 167}
164 168
165_guix_is_dash_p () 169_guix_is_dash_p ()
166{ 170{
167 [ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-p" ] \ 171 _guix_is_short_option p ||
168 || { case "${COMP_WORDS[$COMP_CWORD]}" in 172 _guix_is_long_option profile
169 --profile=*) true;;
170 *) false;;
171 esac }
172} 173}
173 174
174_guix_complete_file () 175_guix_complete_file ()