]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-execute: simplify checks if grep output is empty
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 22 Mar 2018 07:42:02 +0000 (08:42 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 22 Mar 2018 14:57:56 +0000 (15:57 +0100)
grep already indicates if it matched anything by return value.
Additional advantage is then that if the test fails, the unexpected
matching lines are visible in the log output.

test/test-execute/exec-capabilityboundingset-invert.service
test/test-execute/exec-privatenetwork-yes.service

index fd5d248702f43257ce963b8499b33bcd7ebab613..1abe3906016d210231d8f4c539e007d36ffb7de3 100644 (file)
@@ -2,6 +2,6 @@
 Description=Test for CapabilityBoundingSet
 
 [Service]
-ExecStart=/bin/sh -x -c 'c=$$(capsh --print | grep "^Bounding set .*cap_chown"); test -z "$$c"'
+ExecStart=/bin/sh -x -c '! capsh --print | grep "^Bounding set .*cap_chown"'
 Type=oneshot
 CapabilityBoundingSet=~CAP_CHOWN
index 3df543ec93c19cd258efc92765f8f20421ef51b5..5077f7eed2c5c6a26b28c0898db5f670919bc5b2 100644 (file)
@@ -2,6 +2,6 @@
 Description=Test for PrivateNetwork
 
 [Service]
-ExecStart=/bin/sh -x -c 'i=$$(ip link | grep ": " | grep -v ": lo:"); test -z "$$i"'
+ExecStart=/bin/sh -x -c '! ip link | grep ": " | grep -v ": lo:"'
 Type=oneshot
 PrivateNetwork=yes