From d6658eaec3c290ca272b9cff2f5f1fce5f3a0cc3 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Tue, 26 May 2020 16:50:36 -0400 Subject: [PATCH] getting prepped for better sudo script these changes pave the way for sudo to seamlessly inherit *most* of the environment of the user without leaving scads of feisty meow junk or user specific stuff behind. --- scripts/core/functions.sh | 14 +++++++------- scripts/core/launch_feisty_meow.sh | 7 +++++++ scripts/core/variables.sh | 13 +++++++++++-- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index 6389b668..e56d8c5f 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -400,13 +400,13 @@ if [ -z "$skip_all" ]; then fi } - # switches from an X:/ form to a /cygdrive/X/path form. this is only useful - # for the cygwin environment currently. - function dos_to_unix_path() { - # we always remove dos slashes in favor of forward slashes. -#old: echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/\1\/\2/' - echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/cygdrive\/\1\/\2/' - } +# # switches from an X:/ form to a /cygdrive/X/path form. this is only useful +# # for the cygwin environment currently. +# function dos_to_unix_path() { +# # we always remove dos slashes in favor of forward slashes. +##old: echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/\1\/\2/' +# echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/cygdrive\/\1\/\2/' +# } # returns a successful value (0) if this system is debian or ubuntu. function debian_like() { diff --git a/scripts/core/launch_feisty_meow.sh b/scripts/core/launch_feisty_meow.sh index 913f82b4..aef7f199 100644 --- a/scripts/core/launch_feisty_meow.sh +++ b/scripts/core/launch_feisty_meow.sh @@ -86,6 +86,13 @@ if [ "$NO_REPAIRS_NEEDED" == "true" ]; then # some preconditions we want to establish before loading anything... # make sure that aliases can be used in non-interactive shells. + # this causes all aliases that are currently defined for this shell to + # be inherited by subshells that this shell starts. this is unusual, + # but is preferred for my workflow in feisty meow scripts; it saves me + # time re-adding aliases if i can count on them already being there. + # this is a problem if you *don't* want the aliases there though. we can + # solve that problem by running bash with the "-O expand_aliases" flags to + # stop the expansion for the next subshell. shopt -s expand_aliases # patch the user variable if we were launched by one of our cron jobs. diff --git a/scripts/core/variables.sh b/scripts/core/variables.sh index d8b44bc8..c843dba6 100644 --- a/scripts/core/variables.sh +++ b/scripts/core/variables.sh @@ -9,8 +9,6 @@ ############## -#hmmm: moved from functions.sh; does that hose everything up? - # defines a variable within the feisty meow environment and remembers that # this is a new or modified definition. if the feisty meow codebase is # unloaded, then so are all the variables that were defined. @@ -30,6 +28,17 @@ return 0 } + # switches from an X:/ form to a /cygdrive/X/path form. this is only useful + # for the cygwin environment currently. + # defined here rather than in functions.sh since we need it when setting variables + # and cannot count on load order during a fresh startup in some circumstances. + function dos_to_unix_path() { + # we always remove dos slashes in favor of forward slashes. +#old: echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/\1\/\2/' + echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/cygdrive\/\1\/\2/' + } + + ############## -- 2.34.1