jaromail

a commandline tool to easily and privately handle your e-mail
git clone git://parazyd.org/jaromail.git
Log | Files | Refs | Submodules | README

commit 1b6377f437237bd7bbad948b91143d3eaa919384
parent ff32d47fa50a263e05711489152636338e78eec1
Author: Jaromil <jaromil@dyne.org>
Date:   Wed, 12 Sep 2012 13:17:15 +0200

improved check for binaries using command builtin instead of which

Diffstat:
Msrc/jaro | 15+++++++--------
Msrc/zlibs/addressbook | 12+++++++-----
Msrc/zlibs/filters | 4++--
Msrc/zlibs/helpers | 4++--
Msrc/zlibs/search | 4+++-
5 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/src/jaro b/src/jaro @@ -40,7 +40,7 @@ TMPRAM=0 typeset -h rm mkdir mutt # which command to use when creating dirs -mkdir="`which mkdir` -m 700 -p" +mkdir="`command -v mkdir` -m 700 -p" # date stamp datestamp=`date '+%d%b%y'` ########################## @@ -203,8 +203,7 @@ MUTTDIR=$WORKDIR/.mutt # use gnome-keyring for passwords on GNU systems GNOMEKEY=0 { test $GNOME_KEYRING_CONTROL } && { - which jaro-gnome-keyring > /dev/null - { test $? = 0 } && { GNOMEKEY=1 } + { command -v jaro-gnome-keyring > /dev/null } && { GNOMEKEY=1 } } @@ -238,7 +237,7 @@ check_bin() { # required programs for req in pinentry fetchmail procmail; do - which $req >/dev/null + command -v $req >/dev/null { test $? != 0 } && { error "Cannot find $req. Please install it." return 1 @@ -246,9 +245,9 @@ check_bin() { done # which wipe command to use - if [ $(which wipe) ]; then + if command -v wipe > /dev/null; then rm="wipe -f -s -q -R /dev/urandom" - elif [ $(which srm) ]; then + elif command -v srm > /dev/null; then rm="srm -m" else rm="rm -f" @@ -256,9 +255,9 @@ check_bin() { func "Rm binary: $rm" # which mutt binary to use - if [ $(which mutt-jaro) ]; then + if command -v mutt-jaro > /dev/null; then mutt="mutt-jaro" - elif [ $(which mutt) ]; then + elif command -v mutt > /dev/null; then mutt="mutt" else error "Cannot find Mutt. Please install it." diff --git a/src/zlibs/addressbook b/src/zlibs/addressbook @@ -299,6 +299,12 @@ edit_abook() { # take argument even without option -l { test -z ${PARAM[1]} } || { list=${PARAM[1]} } + # check if abook binary is found + { command -v abook > /dev/null } || { + error "ABook not found, operation aborted." + return 1 + } + act "Editing addressbook $list" tmp=$TMPDIR/abook.$datestamp.$RANDOM newlock $tmp @@ -343,11 +349,7 @@ EOF c=$(( $c + 1 )) } done - which abook > /dev/null - { test $? != 0 } && { - error "ABook not found" - return 1 - } + # generate abook configuration abookrc=$TMPDIR/abookrc.$datestamp.$RANDOM cat <<EOF > $abookrc diff --git a/src/zlibs/filters b/src/zlibs/filters @@ -91,8 +91,8 @@ EOF # MUTT MAILCAP wwwtext=w3m -{ which lynx > /dev/null } && { wwwtext=lynx } -{ which elinks > /dev/null } && { wwwtext=elinks } +{ command -v lynx > /dev/null } && { wwwtext=lynx } +{ command -v elinks > /dev/null } && { wwwtext=elinks } cat <<EOF > $MUTTDIR/mailcap text/html; ${wwwtext} -dump %s; nametemplate=%s.html; copiousoutput application/*; a=${WORKDIR}/tmp && f=\`basename %s\` && rm -f \$a/\$f && cp %s \$a/\$f && jaro preview \$a/\$f diff --git a/src/zlibs/helpers b/src/zlibs/helpers @@ -100,9 +100,9 @@ edit_file() { ps ax|grep '[e]macs' > /dev/null if [ $? = 0 ]; then emacsclient -a ${=PARAM} - elif [ `which vim` ]; then + elif command -v vim > /dev/null; then jarovim ${=PARAM} - elif [ `which nano` ]; then + elif command -v nano > /dev/null; then nano -m -S -Q ">" -I -E -D -T 4 -U -W -c -i -k -r 72 ${=PARAM} else error "No editor found, please configure the JARO_EDITOR environment variable." diff --git a/src/zlibs/search b/src/zlibs/search @@ -24,7 +24,9 @@ ## Search into maildirs # using mairix search() { - { which mairix > /dev/null } || { return 1 } + { command -v mairix > /dev/null } || { + error "Mairix not found, operation aborted." + return 1 } id=$RANDOM rc=$TMPDIR/search.conf.$id typeset -al expr