X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=scripts%2Fcore%2Ffunctions.sh;h=6f447a74b79e4d07bfbba3cf677a2f182bf4d9de;hb=8f9e4d54ecd9cca39c975b3107fb69a7b58e0057;hp=924266dc781f911ae5ec5c7f382e955ae22f5176;hpb=de69513cea7b1ce2e300083b775cf8ab372d3b9b;p=feisty_meow.git diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index 924266dc..6f447a74 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -275,6 +275,20 @@ if [ -z "$skip_all" ]; then echo } + # a wrapper for the which command that finds items on the path. some OSes + # do not provide which, so we want to not be spewing errors when that + # happens. + function whichable() + { + to_find="$1"; shift + which which &>/dev/null + if [ $? -ne 0 ]; then + # there is no which command here. we produce nothing due to this. + echo + fi + echo $(which $to_find) + } + # copies a set of custom scripts into the proper location for feisty meow # to merge their functions and aliases with the standard set. function recustomize() @@ -305,6 +319,29 @@ if [ -z "$skip_all" ]; then regenerate } + function add_cygwin_drive_mounts() { + for i in c d e f g h q z ; do + ln -s /cygdrive/$i $i + 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/" "$file" + } + function function_sentinel() { return 0; } if [ ! -z "$SHELL_DEBUG" ]; then echo function definitions end....; fi