From 29a753df7682424a0ea505698d548f85c514fad5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 4 Aug 2016 01:45:07 +0200 Subject: journalctl: add new output mode "short-full" (#3880) This new output mode formats all timestamps using the usual format_timestamp() call we use pretty much everywhere else. Timestamps formatted this way are some ways more useful than traditional syslog timestamps as they include weekday, month and timezone information, while not being much longer. They are also not locale-dependent. The primary advantage however is that they may be passed directly to journalctl's --since= and --until= switches as soon as #3869 is merged. While we are at it, let's also add "short-unix" to shell completion. --- shell-completion/bash/journalctl | 2 +- shell-completion/bash/systemctl.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'shell-completion/bash') diff --git a/shell-completion/bash/journalctl b/shell-completion/bash/journalctl index 53bedcd92e..a999a10df1 100644 --- a/shell-completion/bash/journalctl +++ b/shell-completion/bash/journalctl @@ -65,7 +65,7 @@ _journalctl() { compopt -o filenames ;; --output|-o) - comps='short short-iso short-precise short-monotonic verbose export json json-pretty json-sse cat' + comps='short short-full short-iso short-precise short-monotonic short-unix verbose export json json-pretty json-sse cat' ;; --field|-F) comps=$(journalctl --fields | sort 2>/dev/null) diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in index 6f2b3f122c..2a45dcbba0 100644 --- a/shell-completion/bash/systemctl.in +++ b/shell-completion/bash/systemctl.in @@ -145,7 +145,7 @@ _systemctl () { comps='full enable-only disable-only' ;; --output|-o) - comps='short short-iso short-precise short-monotonic verbose export json + comps='short short-full short-iso short-precise short-monotonic short-unix verbose export json json-pretty json-sse cat' ;; --machine|-M) -- cgit v1.2.3-54-g00ecf From 0cea2697edd26113d5328d235572e4b0c77b8779 Mon Sep 17 00:00:00 2001 From: Marcos Mello Date: Fri, 2 Sep 2016 07:18:11 -0300 Subject: shell-completion: add systemd-resolve --status (#4085) From be371fe. --- shell-completion/bash/systemd-resolve | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'shell-completion/bash') diff --git a/shell-completion/bash/systemd-resolve b/shell-completion/bash/systemd-resolve index 0c501c9405..f59482fe23 100644 --- a/shell-completion/bash/systemd-resolve +++ b/shell-completion/bash/systemd-resolve @@ -36,8 +36,8 @@ _systemd-resolve() { local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local -A OPTS=( [STANDALONE]='-h --help --version -4 -6 - --service --openpgp --tlsa --statistics --reset-statistics - --service-address=no --service-txt=no + --service --openpgp --tlsa --status --statistics + --reset-statistics --service-address=no --service-txt=no --cname=no --search=no --legend=no' [ARG]='-i --interface -p --protocol -t --type -c --class' ) -- cgit v1.2.3-54-g00ecf From b1bdb6496c07fc4fcf3f0feae69b5ef89ae557d9 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 9 Sep 2016 16:20:05 +0900 Subject: bash-completion: systemctl: do not pass masked or not-found units to filter Also, add new function __filter_units_by_properties() for filtering units by multiple properties, and make __get_startable_units() use it. fixes #4114 --- shell-completion/bash/systemctl.in | 43 ++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'shell-completion/bash') diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in index 2a45dcbba0..e62cfa57a9 100644 --- a/shell-completion/bash/systemctl.in +++ b/shell-completion/bash/systemctl.in @@ -51,6 +51,37 @@ __filter_units_by_property () { done } +__filter_units_by_properties () { + local mode=$1 properties=$2 values=$3 ; shift 3 + local units=("$@") + local props + IFS=$'\n' read -rd '' -a props < \ + <(__systemctl $mode show --property "$properties" -- "${units[@]}") + IFS=$',' read -r -a properties < <(echo $properties) + IFS=$',' read -r -a values < <(echo $values) + local conditions=() + for ((i=0; i < ${#properties[*]}; i++)); do + for ((j=0; j < ${#properties[*]}; j++)); do + if [[ ${props[i]%%=*} == ${properties[j]} ]]; then + conditions+=( "${properties[j]}=${values[j]}" ) + fi + done + done + local flag + for ((i=0; i < ${#units[*]}; i++)); do + flag=1 + for ((j=0; j < ${#conditions[*]}; j++)); do + if [[ "${props[ i * ${#conditions[*]} + j]}" != "${conditions[j]}" ]]; then + flag= + break + fi + done + if [[ -n $flag ]]; then + echo " ${units[i]}" + fi + done +} + __get_all_units () { { __systemctl $1 list-unit-files; __systemctl $1 list-units --all; } \ | { while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; }; } __get_template_names () { __systemctl $1 list-unit-files \ @@ -60,12 +91,12 @@ __get_active_units () { __systemctl $1 list-units \ | { while read -r a b; do echo " $a"; done; }; } __get_startable_units () { # find startable inactive units - __filter_units_by_property $mode ActiveState inactive $( - __filter_units_by_property $mode CanStart yes $( - __systemctl $mode list-unit-files --state enabled,disabled,static | \ - { while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; } - __systemctl $mode list-units --state inactive,failed | \ - { while read -r a b; do echo " $a"; done; } )) + __filter_units_by_properties $mode ActiveState,CanStart inactive,yes $( + { __systemctl $mode list-unit-files --state enabled,enabled-runtime,linked,linked-runtime,static,indirect,disabled,generated,transient | \ + { while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; } + __systemctl $mode list-units --state inactive,failed | \ + { while read -r a b c; do [[ $b == "loaded" ]] && echo " $a"; done; } + } | sort -u ) } __get_restartable_units () { # filter out masked and not-found -- cgit v1.2.3-54-g00ecf From c07c80bc969fdb745593a86c8a34758722eeb29a Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 14 Sep 2016 15:22:45 +0900 Subject: bash-completion: systemctl: use local variables --- shell-completion/bash/systemctl.in | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'shell-completion/bash') diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in index e62cfa57a9..dcf71a1f51 100644 --- a/shell-completion/bash/systemctl.in +++ b/shell-completion/bash/systemctl.in @@ -41,7 +41,7 @@ __contains_word () { __filter_units_by_property () { local mode=$1 property=$2 value=$3 ; shift 3 local units=("$@") - local props + local props i IFS=$'\n' read -rd '' -a props < \ <(__systemctl $mode show --property "$property" -- "${units[@]}") for ((i=0; $i < ${#units[*]}; i++)); do @@ -54,12 +54,11 @@ __filter_units_by_property () { __filter_units_by_properties () { local mode=$1 properties=$2 values=$3 ; shift 3 local units=("$@") - local props + local props i j conditions=() IFS=$'\n' read -rd '' -a props < \ <(__systemctl $mode show --property "$properties" -- "${units[@]}") IFS=$',' read -r -a properties < <(echo $properties) IFS=$',' read -r -a values < <(echo $values) - local conditions=() for ((i=0; i < ${#properties[*]}; i++)); do for ((j=0; j < ${#properties[*]}; j++)); do if [[ ${props[i]%%=*} == ${properties[j]} ]]; then @@ -67,16 +66,13 @@ __filter_units_by_properties () { fi done done - local flag for ((i=0; i < ${#units[*]}; i++)); do - flag=1 for ((j=0; j < ${#conditions[*]}; j++)); do if [[ "${props[ i * ${#conditions[*]} + j]}" != "${conditions[j]}" ]]; then - flag= break fi done - if [[ -n $flag ]]; then + if (( j == ${#conditions[*]} )); then echo " ${units[i]}" fi done -- cgit v1.2.3-54-g00ecf From c0f9116d6cd795edd9d4df8d27a87a7232d3e675 Mon Sep 17 00:00:00 2001 From: Davide Cavalca Date: Wed, 14 Sep 2016 13:38:53 -0700 Subject: shell-completion: add --wait to systemd-run completions (#4140) --- shell-completion/bash/systemd-run | 3 ++- shell-completion/zsh/_systemd-run | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'shell-completion/bash') diff --git a/shell-completion/bash/systemd-run b/shell-completion/bash/systemd-run index 022331e6a9..4116ba7eca 100644 --- a/shell-completion/bash/systemd-run +++ b/shell-completion/bash/systemd-run @@ -36,7 +36,8 @@ _systemd_run() { -r --remain-after-exit --send-sighup -H --host -M --machine --service-type --on-active --on-boot --on-startup --on-unit-active --on-unit-inactive --on-calendar --timer-property -t --pty -q --quiet --no-block - --uid --gid --nice --setenv -p --property --no-ask-password' + --uid --gid --nice --setenv -p --property --no-ask-password + --wait' local mode=--system local i diff --git a/shell-completion/zsh/_systemd-run b/shell-completion/zsh/_systemd-run index 6362b97766..da9f73a6d0 100644 --- a/shell-completion/zsh/_systemd-run +++ b/shell-completion/zsh/_systemd-run @@ -57,4 +57,5 @@ _arguments \ '--on-unit-inactive=[Run after SEC seconds from the last deactivation]:SEC' \ '--on-calendar=[Realtime timer]:SPEC' \ '--timer-property=[Set timer unit property]:NAME=VALUE' \ + '--wait=[Wait until service stopped again]' \ '*::command:_command' -- cgit v1.2.3-54-g00ecf