From: Fred Hamster Date: Mon, 16 Dec 2024 21:29:51 +0000 (-0500) Subject: simplifications X-Git-Tag: 2.140.189^2~69 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=61660ea9501b892ba4c4fa170884ba641e602e1c;p=feisty_meow.git simplifications --- diff --git a/scripts/core/launch_feisty_meow.sh b/scripts/core/launch_feisty_meow.sh index 2e773361..cdd28ea1 100644 --- a/scripts/core/launch_feisty_meow.sh +++ b/scripts/core/launch_feisty_meow.sh @@ -105,32 +105,6 @@ if [ "$NO_REPAIRS_NEEDED" == "true" ]; then # the dollar signs in variable names. shopt -u progcomp - #### - # (function borrowed from our own variables.sh) - # a handy helper method that turns a potentially gross USER variable into - # a nice clean one (by removing email domains). - export SANITIZED_USER - function sanitized_username() { - if [ ! -z "$SANITIZED_USER" ]; then - echo -n "$SANITIZED_USER" - fi - export SANITIZED_USER="$(echo "$USER" | sed -e 's/@[a-zA-Z0-9_.]*//')" - echo -n "$SANITIZED_USER" - } - # call the method to ensure the variable gets loaded. - sanitized_username &> /dev/null - ##### - - # patch the user variable if we were launched by one of our cron jobs. - # first we set USER to not use the full email style version, if that's what already exists. - if [ ! -z "$USER" -a "$(echo "${USER/*@*/yeps}")" == "yeps" ]; then - USER="$(sanitized_username)" - fi - # then we check if the USER variable isn't set, and use CRONUSER from the cron templates, if defined. - if [ -z "$USER" -a ! -z "$CRONUSER" ]; then - export USER="$CRONUSER" - fi - # use the xauth info if we were given one in the environment. # this allows root or other su'd identities to create windows with same # display variable. @@ -187,6 +161,16 @@ if [ "$NO_REPAIRS_NEEDED" == "true" ]; then # it will decide what variables need to be set again. source "$FEISTY_MEOW_SCRIPTS/core/variables.sh" + # patch the user variable if we were launched by one of our cron jobs. + # first we set USER to not use the full email style version, if that's what already exists. + if [ ! -z "$USER" -a "$(echo "${USER/*@*/yeps}")" == "yeps" ]; then + USER="$(sanitized_username)" + fi + # then we check if the USER variable isn't set, and use CRONUSER from the cron templates, if defined. + if [ -z "$USER" -a ! -z "$CRONUSER" ]; then + export USER="$CRONUSER" + fi + ############## # include helpful functions. we do this every time rather than making it part diff --git a/scripts/core/variables.sh b/scripts/core/variables.sh index cd1e1356..758d92ea 100644 --- a/scripts/core/variables.sh +++ b/scripts/core/variables.sh @@ -42,10 +42,9 @@ return 0 # a nice clean one (by removing email domains). export SANITIZED_USER function sanitized_username() { - if [ ! -z "$SANITIZED_USER" ]; then - echo -n "$SANITIZED_USER" + if [ -z "$SANITIZED_USER" ]; then + export SANITIZED_USER="$(echo "$USER" | sed -e 's/@[a-zA-Z0-9_.]*//')" fi - export SANITIZED_USER="$(echo "$USER" | sed -e 's/@[a-zA-Z0-9_.]*//')" echo -n "$SANITIZED_USER" } # call the method to ensure the variable gets loaded.