From 22bbd7c6d7bbb09a5ba955d30ceebf93693d23fb Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Sat, 1 Oct 2016 19:52:28 -0400 Subject: [PATCH] fixed alias issues for subshells! also fixed the variable, alias and function names used for sentinels to line up nicely, including a user customization sentinel. --- customizing/fred/fred_variables.sh | 4 +++- scripts/core/common.alias | 4 ++-- scripts/core/functions.sh | 16 ++++++++-------- scripts/core/launch_feisty_meow.sh | 3 ++- scripts/core/variables.sh | 6 ++++-- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/customizing/fred/fred_variables.sh b/customizing/fred/fred_variables.sh index 2e12fa0c..e783f8eb 100644 --- a/customizing/fred/fred_variables.sh +++ b/customizing/fred/fred_variables.sh @@ -1,7 +1,7 @@ # these are my personal overrides. --fred. -if [ -z "$NETHACKOPTIONS" ]; then +if [ -z "$USER_CUSTOMIZATIONS_LOADED" ]; then # if we don't see the nethack variable defined, this probably hasn't run yet. # The cloud directory is our new repository that's always available. It serves as our @@ -60,6 +60,8 @@ if [ -z "$NETHACKOPTIONS" ]; then # options for the lame mp3 encoder. export LAMEOPT="--alt-preset extreme" + # customization sentinel can be set now. + export USER_CUSTOMIZATIONS_LOADED=true fi diff --git a/scripts/core/common.alias b/scripts/core/common.alias index cf8f49b3..1cf5be3a 100644 --- a/scripts/core/common.alias +++ b/scripts/core/common.alias @@ -114,8 +114,8 @@ unalias fredme &>/dev/null ############## -# set the sentinel variable that says this file was handled. -export CORE_ALIASES_LOADED=true +# set the sentinel alias that says this file was handled. +alias CORE_ALIASES_LOADED=true ############## diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index a7babc22..629bd59b 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -4,7 +4,7 @@ # test whether we've been here before or not. skip_all= -function_sentinel &>/dev/null +type function_sentinel &>/dev/null if [ $? -eq 0 ]; then # there was no error, so we can skip the inits. if [ ! -z "$SHELL_DEBUG" ]; then @@ -357,12 +357,9 @@ if [ -z "$skip_all" ]; then echo "regenerating feisty meow script environment." bash $FEISTY_MEOW_SCRIPTS/core/reconfigure_feisty_meow.sh echo - # force a full reload by turning off sentinel variable and alias. - # the nethack one is used by fred's customizations. - # interesting note perhaps: found that the NETHACKOPTIONS variable was - # not being unset correctly when preceded by an alias. split them up - # like they are now due to that bug. - unset -v CORE_ALIASES_LOADED FEISTY_MEOW_LOADING_DOCK NECHUNG NETHACKOPTIONS + # force a full reload by turning off sentinel variables and methods. + unset -v CORE_VARIABLES_LOADED FEISTY_MEOW_LOADING_DOCK USER_CUSTOMIZATIONS_LOADED + unalias CORE_ALIASES_LOADED unset -f function_sentinel # reload feisty meow environment in current shell. source $FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh @@ -665,7 +662,10 @@ return 0 ############## - function function_sentinel() { return 0; } + function function_sentinel() + { + return 0; + } if [ ! -z "$SHELL_DEBUG" ]; then echo "feisty meow function definitions done."; fi diff --git a/scripts/core/launch_feisty_meow.sh b/scripts/core/launch_feisty_meow.sh index b3d52052..9bbcec14 100644 --- a/scripts/core/launch_feisty_meow.sh +++ b/scripts/core/launch_feisty_meow.sh @@ -95,7 +95,8 @@ if [ -z "$LIGHTWEIGHT_INIT" ]; then if [ ! -z "$SHELL_DEBUG" ]; then echo "heavyweight init begins..."; fi # set up the aliases for the shell, but only if they are not already set. - if [ -z "$CORE_ALIASES_LOADED" ]; then + type CORE_ALIASES_LOADED &>/dev/null + if [ $? -ne 0 ]; then if [ ! -z "$SHELL_DEBUG" ]; then echo "the aliases were missing, now they are being added..." fi diff --git a/scripts/core/variables.sh b/scripts/core/variables.sh index b71defbe..1be1278d 100644 --- a/scripts/core/variables.sh +++ b/scripts/core/variables.sh @@ -49,7 +49,7 @@ define_yeti_variable TERM ############## # we'll run this again only if we think it's needed. -if [ -z "$NECHUNG" ]; then +if [ -z "$CORE_VARIABLES_LOADED" ]; then if [ ! -z "$SHELL_DEBUG" ]; then echo variables initialization begins...; fi @@ -242,6 +242,8 @@ if [ -z "$NECHUNG" ]; then define_yeti_variable SHUNIT_DIR="$FEISTY_MEOW_SCRIPTS/shunit" ############## + + define_yeti_variable CORE_VARIABLES_LOADED=true if [ ! -z "$SHELL_DEBUG" ]; then echo variables initialization ends....; fi fi @@ -263,4 +265,4 @@ for i in $FEISTY_MEOW_LOADING_DOCK/custom/*.sh; do fi source "$i" done - + -- 2.34.1