X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=scripts%2Fcore%2Ffunctions.sh;h=41d94b938e9144d29218e8fa31961b8a11f2a39f;hb=aab3d5746e13a49520cb5fb698e873f89d5666c2;hp=f6a9beb37fb55dccc23253001d11b84026d221ab;hpb=1915a56e69a320fa3a3c2d944cf120f2c958e287;p=feisty_meow.git diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index f6a9beb3..41d94b93 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -33,6 +33,35 @@ if [ -z "$skip_all" ]; then cd "$1" } + # displays the value of a variable in bash friendly format. + function var() { + while true; do + local varname="$1"; shift + if [ -z "$varname" ]; then + break + fi + if [ -z "${!varname}" ]; then + echo "$varname undefined" + else + echo "$varname=${!varname}" + fi + done + } + + function success_sound() + { + if [ ! -z "$CLAM_FINISH_SOUND" ]; then + bash $FEISTY_MEOW_SCRIPTS/multimedia/sound_play.sh "$CLAM_FINISH_SOUND" + fi + } + + function error_sound() + { + if [ ! -z "$CLAM_ERROR_SOUND" ]; then + bash $FEISTY_MEOW_SCRIPTS/multimedia/sound_play.sh "$CLAM_ERROR_SOUND" + fi + } + # checks the result of the last command that was run, and if it failed, # then this complains and exits from bash. the function parameters are # used as the message to print as a complaint. @@ -40,6 +69,7 @@ if [ -z "$skip_all" ]; then { if [ $? -ne 0 ]; then echo -e "failed on: $*" + error_sound exit 1 fi } @@ -230,7 +260,7 @@ if [ -z "$skip_all" ]; then # label if they're doing an su with the sudo. function sudo() { local first_command="$1" - /usr/bin/sudo $* + /usr/bin/sudo "$@" if [ "$first_command" == "su" ]; then # yep, they were doing an su, but they're back now. bash $FEISTY_MEOW_SCRIPTS/tty/label_terminal_with_infos.sh @@ -342,6 +372,8 @@ if [ -z "$skip_all" ]; then sed -i -e "s%$pattern%$replacement%g" "$file" } + ############## + function function_sentinel() { return 0; } if [ ! -z "$SHELL_DEBUG" ]; then echo function definitions end....; fi