From b549e7bbb5fa55cacf97b9aa405f73c030cf712b Mon Sep 17 00:00:00 2001 From: talyz Date: Wed, 23 Feb 2022 12:48:51 +0100 Subject: genJqSecretsReplacementSnippet: Fix error handling With the previous change that enabled error propagation through `inherit_errexit`, the script would fail if `errexit` was set, but `inherit_errexit` was not. This is due to `shopt -p` exiting with an error if the option is disabled. To work around this, use the exit code instead of the text value returned by `shopt -p`. Fixes #160869. --- nixos/lib/utils.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'nixos/lib') diff --git a/nixos/lib/utils.nix b/nixos/lib/utils.nix index 190c4db4d49..733f9ca522b 100644 --- a/nixos/lib/utils.nix +++ b/nixos/lib/utils.nix @@ -150,7 +150,8 @@ rec { rm '${output}' fi - inherit_errexit_restore=$(shopt -p inherit_errexit) + inherit_errexit_enabled=0 + shopt -pq inherit_errexit && inherit_errexit_enabled=1 shopt -s inherit_errexit '' + concatStringsSep @@ -170,7 +171,7 @@ rec { ' <<'EOF' ${builtins.toJSON set} EOF - $inherit_errexit_restore + (( ! $inherit_errexit_enabled )) && shopt -u inherit_errexit ''; systemdUtils = { -- cgit 1.4.1