shell-completion/zsh: silence error when machinectl is not installed
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 20 Oct 2022 05:48:02 +0000 (07:48 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 20 Oct 2022 07:58:00 +0000 (09:58 +0200)
commit4e9183059a5738cd19a8bee76189889087c0610e
tree29b90ff812f87e547a8a04f8a947b2453a412244
parent99b8149ae13730a0e87507a5375dabf22bc3f3b7
shell-completion/zsh: silence error when machinectl is not installed

This fixes a few unrelated issues:
- when ENABLE_MACHINED is false, machinectl is not installed, but _sd_machines
  is still used in a few places that want to complete -M and such.
  Also, bash completion calls machinectl in various places.
  Make missing machinectl mean "no machines" in this case, so
  that no error is generated in the callers.
- machinectl list --full would print multiple lines of output per machine,
  breaking grep, issue introduced in e2268fa43742ece4a5cdc2e93f731b2bb2fcc883.
  Using --max-addresses=1 would fix the issue, but let's use
  --max-addresses=0 because we now can.
- the lists used in various places were slightly different for no good reason.
- don't use a subshell if not necessary.

The code for bash still uses the same combined list of images and running
machines for various commands. The zsh code uses images for start/clone, and
running machines for the rest. Maybe something to fix in the future.

Replaces #25048.
13 files changed:
shell-completion/bash/busctl
shell-completion/bash/journalctl
shell-completion/bash/loginctl
shell-completion/bash/machinectl
shell-completion/bash/portablectl
shell-completion/bash/systemctl.in
shell-completion/bash/systemd-analyze
shell-completion/bash/systemd-cgls
shell-completion/bash/systemd-cgtop
shell-completion/bash/systemd-nspawn
shell-completion/bash/systemd-run
shell-completion/bash/timedatectl
shell-completion/zsh/_sd_machines