From: Fred Hamster Date: Mon, 16 Dec 2024 20:44:24 +0000 (-0500) Subject: improvements for sanitized username X-Git-Tag: 2.140.189^2~73 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=bb44308738c8b609b194555af6302a71ff653249;p=feisty_meow.git improvements for sanitized username saves value in an exported variable so not calling sed on every usage. --- diff --git a/scripts/core/variables.sh b/scripts/core/variables.sh index b0bc95a6..9b535889 100644 --- a/scripts/core/variables.sh +++ b/scripts/core/variables.sh @@ -40,8 +40,13 @@ return 0 # 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() { - echo $USER | sed -e 's/@[a-zA-Z0-9_.]*//' + 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" } ##############