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 fd5d248..1abe390 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 3df543e..5077f7e 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