diff options
| author | Michael Hoang <enzime@users.noreply.github.com> | 2024-10-24 23:55:25 +1100 |
|---|---|---|
| committer | Michael Hoang <enzime@users.noreply.github.com> | 2024-10-27 21:26:19 +1100 |
| commit | fd6660cb9182fde5e593246e311dc3c2dd4b9d13 (patch) | |
| tree | b4ff5faff0098a1cd0e4a6f7e18109ecf69a5b6b /pkgs | |
| parent | 2eb472230a5400c81d9008014888b4bff23bcf44 (diff) | |
tests: fix negative asserts with `grep` not working
Using `grep -v` without `-z` will return 0 even if there is a match
found as all the non-matching lines will be matched. Instead of using
`grep -vqz`, `(! grep ...)` is more readable.
The brackets are necessary as `! grep` will not trigger `set -e`[0], so we
run it inside a subshell to use its non-zero exit code.
[0]: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#The-Set-Builtin
Diffstat (limited to 'pkgs')
| -rw-r--r-- | pkgs/darwin-installer/default.nix | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/pkgs/darwin-installer/default.nix b/pkgs/darwin-installer/default.nix index 36643a3..37a391c 100644 --- a/pkgs/darwin-installer/default.nix +++ b/pkgs/darwin-installer/default.nix @@ -118,7 +118,7 @@ stdenv.mkDerivation { test -e /etc/static echo >&2 "checking profile" cat /etc/profile - grep -v nix-daemon.sh /etc/profile + (! grep nix-daemon.sh /etc/profile) echo >&2 "checking /run/current-system" readlink /run test -e /run |
