mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
zsh: guard session variables under nounset
Use parameter expansion with a default value when checking Home Manager's session-variable sentinels. Users with zsh NO_UNSET or shell nounset enabled were seeing parameter-not-set errors before the generated session variables had a chance to export the sentinel variables. Update the home session-variable and zsh fixtures to cover the generated guards.
This commit is contained in:
@@ -657,7 +657,7 @@ in
|
||||
destination = "/etc/profile.d/hm-session-vars.sh";
|
||||
text = ''
|
||||
# Only source this once.
|
||||
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
|
||||
if [ -n "''${__HM_SESS_VARS_SOURCED-}" ]; then return; fi
|
||||
export __HM_SESS_VARS_SOURCED=1
|
||||
|
||||
${config.lib.shell.exportAll cfg.sessionVariables}
|
||||
|
||||
@@ -486,7 +486,7 @@ in
|
||||
. "${config.home.sessionVariablesPackage}/etc/profile.d/hm-session-vars.sh"
|
||||
|
||||
# Only source this once
|
||||
if [[ -z "$__HM_ZSH_SESS_VARS_SOURCED" ]]; then
|
||||
if [[ -z "''${__HM_ZSH_SESS_VARS_SOURCED-}" ]]; then
|
||||
export __HM_ZSH_SESS_VARS_SOURCED=1
|
||||
${envVarsStr}
|
||||
fi
|
||||
|
||||
@@ -6,7 +6,7 @@ let
|
||||
|
||||
linuxExpected = ''
|
||||
# Only source this once.
|
||||
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
|
||||
if [ -n "''${__HM_SESS_VARS_SOURCED-}" ]; then return; fi
|
||||
export __HM_SESS_VARS_SOURCED=1
|
||||
|
||||
export IS_EMPTY=""
|
||||
@@ -25,7 +25,7 @@ let
|
||||
|
||||
darwinExpected = ''
|
||||
# Only source this once.
|
||||
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
|
||||
if [ -n "''${__HM_SESS_VARS_SOURCED-}" ]; then return; fi
|
||||
export __HM_SESS_VARS_SOURCED=1
|
||||
|
||||
export IS_EMPTY=""
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
. "/nix/store/00000000000000000000000000000000-hm-session-vars.sh/etc/profile.d/hm-session-vars.sh"
|
||||
|
||||
# Only source this once
|
||||
if [[ -z "$__HM_ZSH_SESS_VARS_SOURCED" ]]; then
|
||||
if [[ -z "${__HM_ZSH_SESS_VARS_SOURCED-}" ]]; then
|
||||
export __HM_ZSH_SESS_VARS_SOURCED=1
|
||||
export IS_EMPTY=""
|
||||
export IS_FALSE=false
|
||||
|
||||
Reference in New Issue
Block a user