the whichable function does the which but also hides errors from not finding the command in question. this is much preferred over seeing errors about "gvim not found" etc.
# decide which drive to compare.
targets="$1"
if [ -z "$targets" ]; then
- targets=($($(which ls) -1 /media/$USER/*))
+ targets=($($(whichable ls) -1 /media/$USER/*))
if [ ${#targets[@]} -gt 1 ]; then
echo "
Please provide a media drive name on the command line, because more than
# An arbitrary format archive lister, although really we are mainly supporting
# tar and zip currently, including compressed formats.
+source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
+
archive_file="$1"; shift
if [ -z "$archive_file" ]; then
echo "This script takes one archive name (in .tar.gz, .zip, etc. formats) and"
fi
if [ -z "$PAGER" ]; then
- PAGER=$(which less)
+ PAGER=$(whichable less)
if [ -z "$PAGER" ]; then
- PAGER=$(which more)
+ PAGER=$(whichable more)
if [ -z "$PAGER" ]; then
PAGER="cat"
fi
##############
# make our functions available to the aliases.
-#hmmm: should this be necessary? will it even work?
source "$FEISTY_MEOW_SCRIPTS/core/functions.sh"
##############
if [ -n "$IS_DARWIN" ]; then
# case for mac os x.
define_yeti_alias exp='open'
- elif [ ! -z "$(which dolphin 2>/dev/null)" ]; then
+ elif [ ! -z "$(whichable dolphin)" ]; then
# we prefer dolphin if available.
define_yeti_alias exp='screen -L -S dolphin-$RANDOM -d -m dolphin '
#--select
- elif [ ! -z "$(which nautilus 2>/dev/null)" ]; then
+ elif [ ! -z "$(whichable nautilus)" ]; then
# launch nautilus if available.
define_yeti_alias exp='nautilus'
else
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() {
# 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:"
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.
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"
# going to work well unless they can be prevented from forking the process
# off.
if [ -z "$EDITOR" ]; then
- EDITOR="$(which gvim)"
+ EDITOR="$(whichable gvim)"
if [ ! -z "$EDITOR" ]; then
# if we found gvim, then add in the no forking flag.
EDITOR+=" --nofork"
fi
fi
if [ -z "$EDITOR" ]; then
- EDITOR="$(which vim)"
+ EDITOR="$(whichable vim)"
fi
if [ -z "$EDITOR" ]; then
- EDITOR="$(which vi)"
+ EDITOR="$(whichable vi)"
fi
if [ -z "$EDITOR" ]; then
- EDITOR="$(which emacs)"
+ EDITOR="$(whichable emacs)"
fi
####
# out of ideas about editors at this point.
if [ ! -d "$JAVA_HOME" ]; then
unset JAVA_HOME
unset JAVA_BIN_PIECE
- if [ -z "$(whichable java 2>/dev/null)" ]; then
+ if [ -z "$(whichable java)" ]; then
intuition_failure JAVA_HOME
fi
fi
ECLIPSE_DIR=$(echo $ECLIPSE_DIR | sed -e 's/^\(.\):/\/cygdrive\/\1/')
fi
fi
-if [ -z "$ECLIPSE_DIR" -a -z "$(whichable eclipse 2>/dev/null)" ]; then
+if [ -z "$ECLIPSE_DIR" -a -z "$(whichable eclipse)" ]; then
intuition_failure ECLIPSE_DIR
fi
export MAX_DEPTH=5
# use our splitter tool for lengthy output if it's available.
-if [ ! -z "$(which splitter 2>/dev/null)" ]; then
- TO_SPLITTER="$(which splitter)"
+if [ ! -z "$(whichable splitter)" ]; then
+ TO_SPLITTER="$(whichable splitter)"
# calculate the number of columsn in the terminal.
cols=$(get_maxcols)
TO_SPLITTER+=" --maxcol $(($cols - 1))"
exit $?
fi
-rpm_available="$(which rpm)"
+rpm_available="$(whichable rpm)"
if [ ! -z "$rpm_available" ]; then
#is that the right phrase for rpm? somewhat forgotten.
rpm -qa | eval $SEEK_PIECE
exit $?
fi
-yum_available="$(which yum)"
+yum_available="$(whichable yum)"
if [ ! -z "$yum_available" ]; then
yum list | eval $SEEK_PIECE
exit $?