chiark / gitweb /
shell-completion: restore completion for -p
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 14 Jul 2014 23:24:46 +0000 (19:24 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 15 Jul 2014 14:06:12 +0000 (10:06 -0400)
It was broken since systemd was moved out of /bin.

For zsh it was never there.

Makefile.am
shell-completion/bash/.gitignore [new file with mode: 0644]
shell-completion/bash/systemctl.in [moved from shell-completion/bash/systemctl with 98% similarity]
shell-completion/zsh/.gitignore [new file with mode: 0644]
shell-completion/zsh/_systemctl.in [moved from shell-completion/zsh/_systemctl with 95% similarity]

index fef6d242c7445c71961987b83d44b163a4422b16..934b91cd1aee9c3015a66e6d6d522e4f3d158cce 100644 (file)
@@ -382,7 +382,6 @@ systemgenerator_PROGRAMS = \
 dist_bashcompletion_DATA = \
        shell-completion/bash/busctl \
        shell-completion/bash/journalctl \
-       shell-completion/bash/systemctl \
        shell-completion/bash/systemd-analyze \
        shell-completion/bash/systemd-cat \
        shell-completion/bash/systemd-cgls \
@@ -394,8 +393,10 @@ dist_bashcompletion_DATA = \
        shell-completion/bash/udevadm \
        shell-completion/bash/kernel-install
 
+nodist_bashcompletion_DATA = \
+       shell-completion/bash/systemctl
+
 dist_zshcompletion_DATA = \
-       shell-completion/zsh/_systemctl \
        shell-completion/zsh/_journalctl \
        shell-completion/zsh/_udevadm \
        shell-completion/zsh/_kernel-install \
@@ -406,6 +407,17 @@ dist_zshcompletion_DATA = \
        shell-completion/zsh/_systemd-delta \
        shell-completion/zsh/_systemd
 
+nodist_zshcompletion_DATA = \
+       shell-completion/zsh/_systemctl
+
+EXTRA_DIST += \
+       shell-completion/bash/systemctl.in \
+       shell-completion/zsh/_systemctl.in
+
+CLEANFILES += \
+       $(nodist_bashcompletion_DATA) \
+       $(nodist_zshcompletion_DATA)
+
 dist_sysctl_DATA = \
        sysctl.d/50-default.conf
 
@@ -5264,6 +5276,9 @@ src/core/macros.%: src/core/macros.%.in
 src/%.policy.in: src/%.policy.in.in
        $(SED_PROCESS)
 
+shell-completion/%: shell-completion/%.in
+       $(SED_PROCESS)
+
 %.rules: %.rules.in
        $(SED_PROCESS)
 
diff --git a/shell-completion/bash/.gitignore b/shell-completion/bash/.gitignore
new file mode 100644 (file)
index 0000000..016e09d
--- /dev/null
@@ -0,0 +1 @@
+/systemctl
similarity index 98%
rename from shell-completion/bash/systemctl
rename to shell-completion/bash/systemctl.in
index e1c842006e3ee885401723d813425e84355e3ad6..4beec4e13f96932b3fd6eeac2defdea427927f15 100644 (file)
@@ -24,8 +24,8 @@ __systemctl() {
 
 __systemd_properties() {
         local mode=$1
-        { __systemctl -a $mode show;
-         systemd --dump-configuration-items; } |
+        { __systemctl $mode show --all;
+         @rootlibexecdir@/systemd --dump-configuration-items; } |
         while IFS='=' read -r key value; do
             [[ $value ]] && echo "$key"
         done
diff --git a/shell-completion/zsh/.gitignore b/shell-completion/zsh/.gitignore
new file mode 100644 (file)
index 0000000..75f13ad
--- /dev/null
@@ -0,0 +1 @@
+/_systemctl
similarity index 95%
rename from shell-completion/zsh/_systemctl
rename to shell-completion/zsh/_systemctl.in
index b6cf66458726cdaa1fcf534cd2b0da13999d0bd1..d9b8d1c0e32b27d7938a15592ec898439df8a96e 100644 (file)
@@ -301,12 +301,25 @@ _unit_types() {
     _values -s , "${_types[@]}"
 }
 
+_unit_properties() {
+  if ( [[ ${+_sys_all_properties} -eq 0 ]] || _cache_invalid SYS_ALL_PROPERTIES ) &&
+    ! _retrieve_cache SYS_ALL_PROPERTIES;
+  then
+    _sys_all_properties=( $( {__systemctl show --all;
+       @rootlibexecdir@/systemd --dump-configuration-items; } | {
+       while IFS='=' read -r a b; do [ -n "$b" ] && echo "$a"; done
+    }) )
+    _store_cache SYS_ALL_PROPRTIES _sys_all_properties
+  fi
+  _values -s , "${_sys_all_properties[@]}"
+}
+
 _arguments -s \
     {-h,--help}'[Show help]' \
     '--version[Show package version]' \
     {-t+,--type=}'[List only units of a particular type]:unit type:_unit_types' \
     '--state=[Display units in the specifyied state]:unit state:_unit_states' \
-    \*{-p+,--property=}'[Show only properties by specific name]:unit property' \
+    {-p+,--property=}'[Show only properties by specific name]:unit property:_unit_properties' \
     {-a,--all}'[Show all units/properties, including dead/empty ones]' \
     '--reverse[Show reverse dependencies]' \
     '--after[Show units ordered after]' \