X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=scripts%2Fcore%2Ffunctions.sh;h=bf92636caaf113568aa1949c62b8e1a75e7f446b;hb=75c2d52632eac5470a48d9b44feb336474a187d8;hp=62e92d5b8fd543d66b0d68e5d63c743d49344aea;hpb=9a3f9b98d7c820bbbfe093c13784694c05f1659d;p=feisty_meow.git diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index 62e92d5b..bf92636c 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -230,7 +230,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 @@ -325,6 +325,23 @@ if [ -z "$skip_all" ]; then done } + + # takes a file to modify, and then it will replace any occurrences of the + # pattern provided as the second parameter with the text in the third + # parameter. + function replace_pattern_in_file() + { + local file="$1"; shift + local pattern="$1"; shift + local replacement="$1"; shift + if [ -z "$file" -o -z "$pattern" -o -z "$replacement" ]; then + echo "replace_pattern_in_file: needs a filename, a pattern to replace, and the" + echo "text to replace that pattern with." + return 1 + fi + sed -i -e "s%$pattern%$replacement%g" "$file" + } + function function_sentinel() { return 0; } if [ ! -z "$SHELL_DEBUG" ]; then echo function definitions end....; fi