more fixes from windows.
[feisty_meow.git] / scripts / core / functions.sh
index 62e92d5b8fd543d66b0d68e5d63c743d49344aea..bf92636caaf113568aa1949c62b8e1a75e7f446b 100644 (file)
@@ -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