foxshell/fn/-z4h-postinstall-systemd
2025-07-04 11:48:40 -05:00

30 lines
731 B
Bash

#!/usr/bin/env zsh
eval "$_z4h_opt"
local comp=$Z4H_PACKAGE_DIR/shell-completion/zsh/_systemctl
[[ -e $comp.in ]] || return 0
[[ -v commands[systemd-path] ]] || return 0
local lib
lib=$(systemd-path system-library-private) || return
if [[ $lib != /* ]]; then
print -Pru2 -- '%F{3}z4h%f: unexpected command output: %F{1}systemd-path system-library-private%f'
return 1
fi
if [[ -x /usr/lib/systemd/systemd ]]; then
local systemd=/usr/lib/systemd
elif [[ -x /lib/systemd/systemd ]]; then
local systemd=/lib/systemd
else
print -Pru2 -- '%F{3}z4h%f: command not found: %F{1}systemd%f'
return 1
fi
local content
content=$(<$comp.in)
print -r -- ${${content//@rootlibexecdir@/$systemd}//\\@/@} >$comp
zf_rm -- $comp.in