From 6ad463a76421022de6762e6f50128febb970dcfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Reu=C3=9Fe?= Date: Wed, 11 Sep 2024 14:03:57 +0200 Subject: [PATCH] zsh: don't be noisy when scripts are run with -u When a script specifies the shell option "nounset" as part of the shebang (e.g., via "#!/usr/bin/env -S zsh -u"), our initialization scripts would produce error messages of the form: __ETC_FOO_SOURCED: parameter not set These messages could probably be confusing to users when running such scripts. By providing a fall-back in the parameter expansion, we can avoid them. This patch does not address interactive shell start-up, where such messages may (or may not) be less problematic. NixOS/nixpkgs@7d84dbdf5b91439f798363559310d86b21bfa86c --- modules/programs/zsh/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index 1f36740b..7574f8e9 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -124,13 +124,13 @@ in # This file is read for all shells. # Only execute this file once per shell. - if [ -n "$__ETC_ZSHENV_SOURCED" ]; then return; fi + if [ -n "''${__ETC_ZSHENV_SOURCED-}" ]; then return; fi __ETC_ZSHENV_SOURCED=1 # Don't execute this file when running in a pure nix-shell. if test -n "$IN_NIX_SHELL"; then return; fi - if [ -z "$__NIX_DARWIN_SET_ENVIRONMENT_DONE" ]; then + if [ -z "''${__NIX_DARWIN_SET_ENVIRONMENT_DONE-}" ]; then . ${config.system.build.setEnvironment} fi @@ -152,7 +152,7 @@ in # This file is read for login shells. # Only execute this file once per shell. - if [ -n "$__ETC_ZPROFILE_SOURCED" ]; then return; fi + if [ -n "''${__ETC_ZPROFILE_SOURCED-}" ]; then return; fi __ETC_ZPROFILE_SOURCED=1 ${concatStringsSep "\n" zshVariables}