X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=scripts%2Fcore%2Ffunctions.sh;h=6989449f702b475fdfe2fb5fa9bc4049334e98d6;hb=78260fb9e066ca6e391494b567b2758073491edc;hp=3a2151b1f22a68814e360c62ecb334df16851911;hpb=7a7838e8e231895336fad4e2920b0bba40ee68cc;p=feisty_meow.git diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index 3a2151b1..6989449f 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -33,6 +33,20 @@ if [ -z "$skip_all" ]; then date +"%Y$sep%m$sep%d$sep%H%M$sep%S" | tr -d '/\n/' } + # 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 + local WHICHER="$(which which 2>/dev/null)" + if [ $? -ne 0 ]; then + # there is no which command here. we produce nothing due to this. + echo + fi + echo $($WHICHER $to_find) + } + # makes a directory of the name specified and then tries to change the # current directory to that directory. function mcd() { @@ -475,7 +489,7 @@ if [ -z "$skip_all" ]; then # overlay for nechung binary so that we can complain less grossly about it when it's missing. function nechung() { - local wheres_nechung=$(which nechung 2>/dev/null) + local wheres_nechung=$(whichable nechung) if [ -z "$wheres_nechung" ]; then echo "The nechung oracle program cannot be found. You may want to consider" echo "rebuilding the feisty meow applications with this command:" @@ -591,20 +605,6 @@ automatic if there is even a small amount of doubt about the issue." 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) - } - function add_cygwin_drive_mounts() { for i in c d e f g h q z ; do #hmmm: improve this by not adding the link if already there, or if the drive is not valid. @@ -860,7 +860,7 @@ return 0 this_host=$(hostname) elif [ ! -z "$(echo $MACHTYPE | grep suse)" ]; then this_host=$(hostname --long) - elif [ -x "$(which hostname 2>/dev/null)" ]; then + elif [ -x "$(whichable hostname)" ]; then this_host=$(hostname) fi echo "$this_host"