fix(users/Profpatsch/lib/eprintenv): don’t crash when env is missing

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 <mail@profpatsch.de>
This commit is contained in:
Profpatsch 2021-02-13 20:53:41 +01:00
parent d6bca70840
commit 18e6db0f21

View file

@ -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