From ae8cb242f2e450c525274732af58b3050399f5bd Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 27 Jul 2021 23:50:33 +0200 Subject: [PATCH] home-environment: use `declare -gr` in activation init This marks the setup variables as read-only. Just to add a bit extra safety. --- modules/lib-bash/activation-init.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/lib-bash/activation-init.sh b/modules/lib-bash/activation-init.sh index f95008ee..eb2dc1ec 100755 --- a/modules/lib-bash/activation-init.sh +++ b/modules/lib-bash/activation-init.sh @@ -5,9 +5,9 @@ function setupVars() { local profilesPath="$nixStateDir/profiles/per-user/$USER" local gcPath="$nixStateDir/gcroots/per-user/$USER" - genProfilePath="$profilesPath/home-manager" - newGenPath="@GENERATION_DIR@"; - newGenGcPath="$gcPath/current-home" + declare -gr genProfilePath="$profilesPath/home-manager" + declare -gr newGenPath="@GENERATION_DIR@"; + declare -gr newGenGcPath="$gcPath/current-home" local greatestGenNum greatestGenNum=$( \ @@ -16,14 +16,15 @@ function setupVars() { | sed -E 's/ *([[:digit:]]+) .*/\1/') if [[ -n $greatestGenNum ]] ; then - oldGenNum=$greatestGenNum - newGenNum=$((oldGenNum + 1)) + declare -gr oldGenNum=$greatestGenNum + declare -gr newGenNum=$((oldGenNum + 1)) else - newGenNum=1 + declare -gr newGenNum=1 fi if [[ -e $profilesPath/home-manager ]] ; then oldGenPath="$(readlink -e "$profilesPath/home-manager")" + declare -gr oldGenPath fi $VERBOSE_ECHO "Sanity checking oldGenNum and oldGenPath"