From 18e6db0f2132cdc827687e2ada1d59aaf29ccb2a Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sat, 13 Feb 2021 20:53:41 +0100 Subject: [PATCH] =?UTF-8?q?fix(users/Profpatsch/lib/eprintenv):=20don?= =?UTF-8?q?=E2=80=99t=20crash=20when=20env=20is=20missing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit eprintenv is a debugging tool, as such the code should probably not crash when the environment variable we want to look at is missing. But we can print a warning instead. Change-Id: I41a24dc0c1cc488587563b85c1adbd089dd364f2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2525 Tested-by: BuildkiteCI Reviewed-by: Profpatsch --- users/Profpatsch/lib.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/users/Profpatsch/lib.nix b/users/Profpatsch/lib.nix index 9dd3cd481..db81c2dfe 100644 --- a/users/Profpatsch/lib.nix +++ b/users/Profpatsch/lib.nix @@ -22,7 +22,10 @@ let ]; eprintenv = depot.nix.writeExecline "eprintenv" { readNArgs = 1; } [ - "fdmove" "-c" "1" "2" bins.printenv "$1" "$@" + "ifelse" [ "fdmove" "-c" "1" "2" bins.printenv "$1" ] + [ "$@" ] + "if" [ eprintf "eprintenv: could not find \"\${1}\" in the environment\n" ] + "$@" ]; # remove everything but a few selected environment variables