diff options
author | Eric Cook <llua@gmx.com> | 2014-07-27 15:07:03 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-07-27 15:27:16 -0400 |
commit | c317a1a19cd9584e07ee43f1b6fafc26c2c75cca (patch) | |
tree | e9710461fb995a1cccdb840131ec5e18646357d9 | |
parent | e2d7c1a0758ce80d7cb439745deefefdffd67655 (diff) |
shell-completion: prevent mangling unit names (bash)
This fixes the issue noted by Zbigniew in most cases.
if a unit's name is enclosed in single quotes completion still
will not happen after the first `\'.
https://bugs.freedesktop.org/show_bug.cgi?id=78388
-rw-r--r-- | shell-completion/bash/systemctl.in | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in index 69ef04b01..64b15df46 100644 --- a/shell-completion/bash/systemctl.in +++ b/shell-completion/bash/systemctl.in | |||
@@ -158,20 +158,25 @@ _systemctl () { | |||
158 | 158 | ||
159 | elif __contains_word "$verb" ${VERBS[ALL_UNITS]}; then | 159 | elif __contains_word "$verb" ${VERBS[ALL_UNITS]}; then |
160 | comps=$( __get_all_units $mode ) | 160 | comps=$( __get_all_units $mode ) |
161 | compopt -o filenames | ||
161 | 162 | ||
162 | elif __contains_word "$verb" ${VERBS[ENABLED_UNITS]}; then | 163 | elif __contains_word "$verb" ${VERBS[ENABLED_UNITS]}; then |
163 | comps=$( __get_enabled_units $mode ) | 164 | comps=$( __get_enabled_units $mode ) |
165 | compopt -o filenames | ||
164 | 166 | ||
165 | elif __contains_word "$verb" ${VERBS[DISABLED_UNITS]}; then | 167 | elif __contains_word "$verb" ${VERBS[DISABLED_UNITS]}; then |
166 | comps=$( __get_disabled_units $mode ) | 168 | comps=$( __get_disabled_units $mode ) |
169 | compopt -o filenames | ||
167 | 170 | ||
168 | elif __contains_word "$verb" ${VERBS[REENABLABLE_UNITS]}; then | 171 | elif __contains_word "$verb" ${VERBS[REENABLABLE_UNITS]}; then |
169 | comps=$( __get_disabled_units $mode; | 172 | comps=$( __get_disabled_units $mode; |
170 | __get_enabled_units $mode ) | 173 | __get_enabled_units $mode ) |
174 | compopt -o filenames | ||
171 | 175 | ||
172 | elif __contains_word "$verb" ${VERBS[STARTABLE_UNITS]}; then | 176 | elif __contains_word "$verb" ${VERBS[STARTABLE_UNITS]}; then |
173 | comps=$( __filter_units_by_property $mode CanStart yes \ | 177 | comps=$( __filter_units_by_property $mode CanStart yes \ |
174 | $( __get_startable_units $mode)) | 178 | $( __get_startable_units $mode)) |
179 | compopt -o filenames | ||
175 | 180 | ||
176 | elif __contains_word "$verb" ${VERBS[RESTARTABLE_UNITS]}; then | 181 | elif __contains_word "$verb" ${VERBS[RESTARTABLE_UNITS]}; then |
177 | comps=$( __filter_units_by_property $mode CanStart yes \ | 182 | comps=$( __filter_units_by_property $mode CanStart yes \ |
@@ -179,24 +184,30 @@ _systemctl () { | |||
179 | | while read -r line; do \ | 184 | | while read -r line; do \ |
180 | [[ "$line" =~ \.(device|snapshot|socket|timer)$ ]] || echo " $line"; \ | 185 | [[ "$line" =~ \.(device|snapshot|socket|timer)$ ]] || echo " $line"; \ |
181 | done )) | 186 | done )) |
187 | compopt -o filenames | ||
182 | 188 | ||
183 | elif __contains_word "$verb" ${VERBS[STOPPABLE_UNITS]}; then | 189 | elif __contains_word "$verb" ${VERBS[STOPPABLE_UNITS]}; then |
184 | comps=$( __filter_units_by_property $mode CanStop yes \ | 190 | comps=$( __filter_units_by_property $mode CanStop yes \ |
185 | $( __get_active_units $mode ) ) | 191 | $( __get_active_units $mode ) ) |
192 | compopt -o filenames | ||
186 | 193 | ||
187 | elif __contains_word "$verb" ${VERBS[RELOADABLE_UNITS]}; then | 194 | elif __contains_word "$verb" ${VERBS[RELOADABLE_UNITS]}; then |
188 | comps=$( __filter_units_by_property $mode CanReload yes \ | 195 | comps=$( __filter_units_by_property $mode CanReload yes \ |
189 | $( __get_active_units $mode ) ) | 196 | $( __get_active_units $mode ) ) |
197 | compopt -o filenames | ||
190 | 198 | ||
191 | elif __contains_word "$verb" ${VERBS[ISOLATABLE_UNITS]}; then | 199 | elif __contains_word "$verb" ${VERBS[ISOLATABLE_UNITS]}; then |
192 | comps=$( __filter_units_by_property $mode AllowIsolate yes \ | 200 | comps=$( __filter_units_by_property $mode AllowIsolate yes \ |
193 | $( __get_all_units $mode ) ) | 201 | $( __get_all_units $mode ) ) |
202 | compopt -o filenames | ||
194 | 203 | ||
195 | elif __contains_word "$verb" ${VERBS[FAILED_UNITS]}; then | 204 | elif __contains_word "$verb" ${VERBS[FAILED_UNITS]}; then |
196 | comps=$( __get_failed_units $mode ) | 205 | comps=$( __get_failed_units $mode ) |
206 | compopt -o filenames | ||
197 | 207 | ||
198 | elif __contains_word "$verb" ${VERBS[MASKED_UNITS]}; then | 208 | elif __contains_word "$verb" ${VERBS[MASKED_UNITS]}; then |
199 | comps=$( __get_masked_units $mode ) | 209 | comps=$( __get_masked_units $mode ) |
210 | compopt -o filenames | ||
200 | 211 | ||
201 | elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[NAME]}; then | 212 | elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[NAME]}; then |
202 | comps='' | 213 | comps='' |
@@ -221,7 +232,7 @@ _systemctl () { | |||
221 | | { while read -r a b; do echo " $a"; done; } ) | 232 | | { while read -r a b; do echo " $a"; done; } ) |
222 | fi | 233 | fi |
223 | 234 | ||
224 | COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) | 235 | COMPREPLY=( $(compgen -o filenames -W '$comps' -- "$cur") ) |
225 | return 0 | 236 | return 0 |
226 | } | 237 | } |
227 | 238 | ||