forked from pool/systemd
68 lines
4.0 KiB
Diff
68 lines
4.0 KiB
Diff
Based on 6d314eca15f6cbda38d82774b210f784d3d4f52a Mon Sep 17 00:00:00 2001
|
|
From: Eric Cook <llua@gmx.com>
|
|
Date: Sat, 26 Jul 2014 11:15:52 -0400
|
|
Subject: [PATCH] shell-completion: prevent mangling unit names
|
|
|
|
Units with literal hex '\xFF' in their names has to be read
|
|
and printed properly.
|
|
dev-disk-byx2dlabel-root.device != dev-disk-by\x2dlabel-root.device
|
|
---
|
|
shell-completion/zsh/_systemctl.in | 20 ++++++++++----------
|
|
1 file changed, 10 insertions(+), 10 deletions(-)
|
|
|
|
diff --git shell-completion/zsh/_systemctl.in shell-completion/zsh/_systemctl.in
|
|
index d364d17..e681ec6 100644
|
|
--- shell-completion/zsh/_systemctl
|
|
+++ shell-completion/zsh/_systemctl
|
|
@@ -100,7 +100,7 @@ _systemctl_all_units()
|
|
if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS ) &&
|
|
! _retrieve_cache SYS_ALL_UNITS;
|
|
then
|
|
- _sys_all_units=( $(__systemctl list-units --all | { while read a b; do echo " $a"; done; }) )
|
|
+ _sys_all_units=( $(__systemctl list-units --all | { while read -r a b; do echo -E - " $a"; done; }) )
|
|
_store_cache SYS_ALL_UNITS _sys_all_units
|
|
fi
|
|
}
|
|
@@ -113,7 +113,7 @@ _systemctl_really_all_units()
|
|
if ( [[ ${+_sys_really_all_units} -eq 0 ]] || _cache_invalid SYS_REALLY_ALL_UNITS ) &&
|
|
! _retrieve_cache SYS_REALLY_ALL_UNITS;
|
|
then
|
|
- all_unit_files=( $(__systemctl list-unit-files | { while read a b; do echo " $a"; done; }) )
|
|
+ all_unit_files=( $(__systemctl list-unit-files | { while read -r a b; do echo -E - " $a"; done; }) )
|
|
_systemctl_all_units
|
|
really_all_units=($_sys_all_units $all_unit_files)
|
|
_sys_really_all_units=(${(u)really_all_units})
|
|
@@ -138,12 +138,12 @@ _filter_units_by_property() {
|
|
done
|
|
}
|
|
|
|
-_systemctl_active_units() {_sys_active_units=( $(__systemctl list-units | { while read a b; do echo " $a"; done; }) )}
|
|
-_systemctl_inactive_units(){_sys_inactive_units=($(__systemctl list-units --all | { while read a b c d; do [[ $c == "inactive" || $c == "failed" ]] && echo " $a"; done; }) )}
|
|
-_systemctl_failed_units() {_sys_failed_units=( $(__systemctl list-units --failed | { while read a b; do echo " $a"; done; }) )}
|
|
-_systemctl_enabled_units() {_sys_enabled_units=( $(__systemctl list-unit-files | { while read a b; do [[ $b == "enabled" ]] && echo " $a"; done; }) )}
|
|
-_systemctl_disabled_units(){_sys_disabled_units=($(__systemctl list-unit-files | { while read a b; do [[ $b == "disabled" ]] && echo " $a"; done; }) )}
|
|
-_systemctl_masked_units() {_sys_masked_units=( $(__systemctl list-unit-files | { while read a b; do [[ $b == "masked" ]] && echo " $a"; done; }) )}
|
|
+_systemctl_active_units() {_sys_active_units=( $(__systemctl list-units | { while read -r a b; do echo -E - " $a"; done; }) )}
|
|
+_systemctl_inactive_units(){_sys_inactive_units=($(__systemctl list-units --all | { while read -r a b c d; do [[ $c == "inactive" || $c == "failed" ]] && echo -E - " $a"; done; }) )}
|
|
+_systemctl_failed_units() {_sys_failed_units=( $(__systemctl list-units --failed | { while read -r a b; do echo -E - " $a"; done; }) )}
|
|
+_systemctl_enabled_units() {_sys_enabled_units=( $(__systemctl list-unit-files | { while read -r a b; do [[ $b == "enabled" ]] && echo -E - " $a"; done; }) )}
|
|
+_systemctl_disabled_units(){_sys_disabled_units=($(__systemctl list-unit-files | { while read -r a b; do [[ $b == "disabled" ]] && echo -E - " $a"; done; }) )}
|
|
+_systemctl_masked_units() {_sys_masked_units=( $(__systemctl list-unit-files | { while read -r a b; do [[ $b == "masked" ]] && echo -E - " $a"; done; }) )}
|
|
|
|
# Completion functions for ALL_UNITS
|
|
for fun in is-active is-failed is-enabled status show cat mask preset help list-dependencies ; do
|
|
@@ -219,8 +219,8 @@ for fun in restart reload-or-restart ; do
|
|
{
|
|
_systemctl_all_units
|
|
compadd "$@" - $( _filter_units_by_property CanStart yes \
|
|
- ${_sys_all_units[*]} | while read line; do \
|
|
- [[ "$line" =~ \.device$ ]] || echo " $line"; \
|
|
+ ${_sys_all_units[*]} | while read -r line; do \
|
|
+ [[ "$line" =~ \.device$ ]] || echo -E - " $line"; \
|
|
done )
|
|
}
|
|
done
|
|
--
|
|
1.7.9.2
|
|
|