Added option --check-inhibitors for non-tty usage
As described in #2680, systemctl did ignore inhibitors if it is not attached to a tty to allow scripts to ignore inhibitors automatically. This pull request preserves this behavior but allows scripts to explicit check inhibitors if required. The new parameter '--check-inhibitors=yes' enables this feature. The old parameter '-i'/'--ignore-inhibitors' was deprecated in favor of '--check-inhibitors=no', the default behaviour can be specified with '--check-inhibitors=auto'. The new parameter is also described in the documentations and shell completions found here.
This commit is contained in:
committed by
Lennart Poettering
parent
65ab27211c
commit
4327574fc1
@@ -125,9 +125,9 @@ _systemctl () {
|
||||
[STANDALONE]='--all -a --reverse --after --before --defaults --force -f --full -l --global
|
||||
--help -h --no-ask-password --no-block --no-legend --no-pager --no-reload --no-wall --now
|
||||
--quiet -q --system --user --version --runtime --recursive -r --firmware-setup
|
||||
--show-types -i --ignore-inhibitors --plain --failed --value --fail --dry-run --wait'
|
||||
--show-types --plain --failed --value --fail --dry-run --wait'
|
||||
[ARG]='--host -H --kill-who --property -p --signal -s --type -t --state --job-mode --root
|
||||
--preset-mode -n --lines -o --output -M --machine --message --timestamp'
|
||||
--preset-mode -n --lines -o --output -M --machine --message --timestamp --check-inhibitors'
|
||||
)
|
||||
|
||||
if __contains_word "--user" ${COMP_WORDS[*]}; then
|
||||
@@ -179,6 +179,9 @@ _systemctl () {
|
||||
--timestamp)
|
||||
comps='pretty us µs utc us+utc µs+utc'
|
||||
;;
|
||||
--check-inhibitors)
|
||||
comps='auto yes no'
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||
return 0
|
||||
|
||||
@@ -443,6 +443,13 @@ done
|
||||
_values -s , "${_styles[@]}"
|
||||
}
|
||||
|
||||
(( $+functions[_systemctl_check_inhibitors] )) ||
|
||||
_systemctl_check_inhibitors() {
|
||||
local -a _modes
|
||||
_modes=(auto yes no)
|
||||
_values -s , "${_modes[@]}"
|
||||
}
|
||||
|
||||
# Build arguments for "systemctl" to be used in completion.
|
||||
local -a _modes; _modes=("--user" "--system")
|
||||
# Use the last mode (they are exclusive and the last one is used).
|
||||
@@ -460,7 +467,7 @@ _arguments -s \
|
||||
'--before[Show units ordered before]' \
|
||||
{-l,--full}"[Don't ellipsize unit names on output]" \
|
||||
'--show-types[When showing sockets, show socket type]' \
|
||||
{-i,--ignore-inhibitors}'[When executing a job, ignore jobs dependencies]' \
|
||||
'--check-inhibitors[Specify if inhibitors should be checked]:mode:_systemctl_check_inhibitors' \
|
||||
{-q,--quiet}'[Suppress output]' \
|
||||
'--no-block[Do not wait until operation finished]' \
|
||||
'--no-legend[Do not print a legend, i.e. the column headers and the footer with hints]' \
|
||||
|
||||
Reference in New Issue
Block a user