numa_hit 68350917471
numa_miss 0
numa_foreign 0
interleave_hit 974
local_node 68350962794
other_node 0
  #   	ˆl–ß=¿J	µ2ÛR‚ œP ¸'n4%1hßÂ„Ay¿ÀÄ 7i    	# systemctl(1) completion                                 -*- shell-script -*-
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# Copyright Â© 2010 Ran Benita

__systemctl() {
    local mode=$1; shift 1
    systemctl $mode --full --legend=no --no-pager --plain "$@" 2>/dev/null
}

__systemd_properties() {
    /usr/lib/systemd/systemd --dump-bus-properties
}

__contains_word () {
    local w word=$1; shift
    for w in "$@"; do
        [[ $w = "$word" ]] && return
    done
}

__filter_units_by_properties () {
    local mode=$1 properties=$2; shift 2
    local units=("$@")
    local props i p n
    local names= count=0

    IFS=$',' read -r -a p < <(echo "Names,$properties")
    n=${#p[*]}
    readarray -t props < \
              <(__systemctl $mode show --property "Names,$properties" -- "${units[@]}")

    for ((i=0; i < ${#props[*]}; i++)); do
        if [[ -z ${props[i]} ]]; then
            if (( count == n )) && [[ -n $names ]]; then
                echo $names
            fi
            names=
            count=0
        else
            (( count++ ))
            if [[ ${props[i]%%=*} == 'Names' ]]; then
                names=${props[i]#*=}
            fi
        fi
    done
    if (( count == n )) && [[ -n $names ]]; then
        echo $names
    fi
}

__get_all_units      () { { __systemctl $1 list-unit-files "$2*"; __systemctl $1 list-units --all "$2*"; } \
                              | { while read -r a b; do echo " $a"; done; }; }
__get_non_template_units() { { __systemctl $1 list-unit-files "$2*"; __systemctl $1 list-units --all "$2*"; } \
                                 | { while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; }; }
__get_template_names () { __systemctl $1 list-unit-files "$2*" \
                              | { while read -r a b; do [[ $a =~ @\. ]] && echo " ${a%%@.*}@"; done; }; }
__get_active_units   () { __systemctl $1 list-units "$2*"      \
                              | { while read -r a b; do echo " $a"; done; }; }

__get_not_masked_unit_files() {
    # filter out masked, not-found, or template units.
    __systemctl $1 list-unit-files --state enabled,enabled-runtime,linked,linked-runtime,static,indirect,disabled,generated,transient "$2*" | \
        { while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; }
}

__get_startable_units () {
    __filter_units_by_properties $1 ActiveState=inactive,CanStart=yes $(
        { __get_not_masked_unit_files $1 $2
          # get inactive template units
          __systemctl $1 list-units --state inactive,failed "$2*" | \
              { while read -r a b c; do [[ $b == "loaded" ]] && echo " $a"; done; }
        } | sort -u )
}
__get_restartable_units () {
    # filter out masked and not-found
    __filter_units_by_properties $1 CanStart=yes $(
        { __get_not_masked_unit_files $1 $2
          __get_active_units $1 $2
        } | sort -u )
}

__get_stoppable_units () {
    # filter out masked and not-found
    local units=$(
        { __get_not_masked_unit_files $1 $2
          __get_active_units $1 $2
        } | sort -u )
    __filter_units_by_properties $1 ActiveState=active,CanStop=yes $units
    __filter_units_by_properties $1 ActiveState=reloading,CanStop=yes $units
    __filter_units_by_properties $1 ActiveState=activating,CanStop=yes $units
}

__get_reloadable_units () {
    # filter out masked and not-found
    __filter_units_by_properties $1 ActiveState=active,CanReload=yes $(
        { __get_not_masked_unit_files $1 $2
          __get_active_units $1 $2
        } | sort -u )
}

__get_failed_units   () { __systemctl $1 list-units "$2*"      \
                              | { while read -r a b c d; do [[ $c == "failed"   ]] && echo " $a"; done; }; }
__get_enabled_units  () { __systemctl $1 list-unit-files "$2*" \
                              | { while read -r a b c  ; do [[ $b == "enabled"  ]] && echo " $a"; done; }; }
__get_disabled_uni