refurbishing for more auto-repair
[feisty_meow.git] / scripts / core / launch_feisty_meow.sh
index 496786a71dcb6fbf6201068f93b6be4b34a591c8..80226899a83bad279656c1986bfc825ebc186775 100644 (file)
 
 ##############
 
-ORIGINATING_FOLDER="$( \cd "$(\dirname "$0")" && /bin/pwd )"
-CORE_SCRIPTS_DIR="$(echo "$ORIGINATING_FOLDER" | tr '\\\\' '/' )"
-THIS_TOOL_NAME="$(basename "$0")"
-# repair some paths that we should always be able to auto-calculate.
-export FEISTY_MEOW_SCRIPTS="$( \cd "$CORE_SCRIPTS_DIR/.." && /bin/pwd )"
-export FEISTY_MEOW_APEX="$( \cd "$FEISTY_MEOW_SCRIPTS/.." && /bin/pwd )"
+# this script cannot handle figuring out where it lives, so approaches that
+# get the WORKDIR will fail.  this is a consequence of this always being used
+# in bash's 'source' directive, which does not pass the script name as
+# argument 0.  instead, we just check for the bad condition of a malconfigured
+# script system and try to repair it.
+
+# check if any crucial folder is hosed.  we will torch the existing config
+# to the extent we can.
+if [ ! -d "$FEISTY_MEOW_SCRIPTS" -o ! -d "$FEISTY_MEOW_APEX" ]; then
+  # wipe out the offending variable(s).
+  unset FEISTY_MEOW_SCRIPTS FEISTY_MEOW_APEX
+  # clean out any unfortunate wrongness that may exist in our generated areas.
+  if [ -d "$"FEISTY_MEOW_LOADING_DOCK ]; then \rm -rf "$FEISTY_MEOW_LOADING_DOCK"; fi
+  if [ -d "$FEISTY_MEOW_GENERATED_STORE" ]; then \rm -rf "$FEISTY_MEOW_GENERATED_STORE"; fi
+  # also wipe any values from the variables pointing at generated stuff.
+  unset FEISTY_MEOW_LOADING_DOCK FEISTY_MEOW_GENERATED_STORE
+  exec "$*"
+fi
 
 ##############