]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shell-completion: fix systemctl set/unset/import-environment 18137/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 5 Jan 2021 11:34:28 +0000 (12:34 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 8 Jan 2021 19:01:40 +0000 (20:01 +0100)
unset-environment is completed with variable names in the environment block.
set-environment the same, but suffixed with "=".
import-environment is completed with variable names in the client environment.

shell-completion/bash/systemctl.in
shell-completion/zsh/_systemctl.in

index f6be3827cff6b142c47881599cf6aa039488f235..b26381a324b5b541ce0ef4708a1d7124562f21a1 100644 (file)
@@ -320,11 +320,20 @@ _systemctl () {
     elif __contains_word "$verb" ${VERBS[JOBS]}; then
         comps=$( __systemctl $mode list-jobs | { while read -r a b; do echo " $a"; done; } )
 
-    elif __contains_word "$verb" ${VERBS[ENVS]}; then
+    elif [ "$verb" = 'unset-environment' ]; then
+        comps=$( __systemctl $mode show-environment \
+                     | while read -r line; do echo " ${line%%=*}"; done )
+        compopt -o nospace
+
+    elif [ "$verb" = 'set-environment' ]; then
         comps=$( __systemctl $mode show-environment \
                      | while read -r line; do echo " ${line%%=*}="; done )
         compopt -o nospace
 
+    elif [ "$verb" = 'import-environment' ]; then
+        COMPREPLY=( $(compgen -A variable -- "$cur_orig") )
+        return 0
+
     elif __contains_word "$verb" ${VERBS[FILE]}; then
         comps=$( compgen -A file -- "$cur" )
         compopt -o filenames
index 4830aeba5f744eb1202f716aa34cf4f1c5888561..22c40898e34dfd0f47ff9873ba13c0b82636dba0 100644 (file)
@@ -365,6 +365,11 @@ for fun in set-environment unset-environment ; do
     }
 done
 
+(( $+functions[_systemctl_import-environment] )) || _systemctl_import-environment()
+{
+    _parameters
+}
+
 (( $+functions[_systemctl_link] )) || _systemctl_link() {
         _sd_unit_files
     }