]> git.ipfire.org Git - thirdparty/systemd.git/commit
systemctl: exit with 1 if no unit files found 15191/head
authorGiedrius Statkevičius <giedriuswork@gmail.com>
Sun, 22 Mar 2020 13:49:55 +0000 (15:49 +0200)
committerGiedrius Statkevičius <giedriuswork@gmail.com>
Wed, 25 Mar 2020 20:20:58 +0000 (22:20 +0200)
commiteeb1542b5ed4e195bf76996493288db489f32a0f
tree9de3bcb86900019d296cb55fbc22ef7fd34c076f
parent1b43e24602010403e8684df7539977264a478688
systemctl: exit with 1 if no unit files found

Add a simple check on the number of unit files that were found: return
`-ENOENT` when none is found from the function and thus `systemctl`
consequently exits with `1` (`EXIT_FAILURE`) if none were found.

Verification:
```bash
root@image:~# systemctl list-unit-files dbus-nonexistant.service; echo
$?
UNIT FILE STATE VENDOR PRESET

0 unit files listed.
1
root@image:~# systemctl list-unit-files dbus.service; echo $?
UNIT FILE    STATE  VENDOR PRESET
dbus.service static enabled

1 unit files listed.
0
```

Fixes #15082.
src/systemctl/systemctl.c