diff options
| author | Sebastian Reuße <seb@schattenkopie.de> | 2024-09-11 14:03:57 +0200 |
|---|---|---|
| committer | Antoine Cotten <hello@acotten.com> | 2024-09-11 14:07:24 +0200 |
| commit | 6ad463a76421022de6762e6f50128febb970dcfc (patch) | |
| tree | d45f0fffb5e899852f041d0e67f0b63e5b533b11 | |
| parent | 7e6c548eef2372cef1287ef45350e29ca5740159 (diff) | |
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
| -rw-r--r-- | modules/programs/zsh/default.nix | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index 1f36740..7574f8e 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} |
