X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fwhatnow2.sh;h=4e767663642c95ac513dea431ac8cac5a84ec91c;hp=a4be1a9277f3668b5d3f6f0fa31209da3c4d615a;hb=d44d7ab7f82b27b1644c7ec93bdbe0fedc0fb4c5;hpb=501f523802eeaed49dc095c9577a9e5f20447a6d diff --git a/uip/whatnow2.sh b/uip/whatnow2.sh index a4be1a9..4e76766 100755 --- a/uip/whatnow2.sh +++ b/uip/whatnow2.sh @@ -19,7 +19,7 @@ printhelp() version() { - if [ $# -eq 0 ] + if [ $1 -eq 0 ] then echo "$0 has no own version number, thus this instead:" folder -Version @@ -38,7 +38,7 @@ usage() exit 0 fi printhelp 1>&2 - exit $1 + exit 1 } get_editor() @@ -61,21 +61,6 @@ get_editor() return fi mheditor=`mhparam 'Editor'` - if [ -n "$mheditor" ] - then - return - fi - if [ -n "$VISUAL" ] - then - mheditor=$VISUAL - return - fi - if [ -n "$EDITOR" ] - then - mheditor=$EDITOR - return - fi - mheditor=vi } get_showproc() @@ -88,14 +73,9 @@ get_realpath() { reldir=`dirname "$1"` filename=`basename "$1"` - cd $reldir + cd "$reldir" echo "$PWD/$filename" - cd - -} - -get_attachmentheader() -{ - header=`mhparam 'Attachment-Header'` + cd "$OLDPWD" } set_lasteditor() @@ -112,7 +92,7 @@ create() fi mhmetafile=$mhdraft.meta touch $mhmetafile - if [ -z $mheditor ] + if [ -z "$mheditor" ] then get_editor fi @@ -163,27 +143,30 @@ list() exec $mhshowproc -file $mhdraft } -send() +sendfunktion() { - export mhaltmsg=`anno -list -component 'mhaltmsg' $mhmetafile` - export mhdist=`anno -list -component 'mhdist' $mhmetafile` - export mhuse=`anno -list -component 'mhuse' $mhmetafile` - export mhfolder=`anno -list -component 'mhfolder' $mhmetafile` - export mhmessages=`anno -list -component 'mhmessages' $mhmetafile` - export mhannotate=`anno -list -component 'mhannotate' $mhmetafile` - rm -f $mhmetafile - exec send "$@" $mhdraft + export mhaltmsg=`anno -list -component 'mhaltmsg' "$mhmetafile"` + export mhdist=`anno -list -component 'mhdist' "$mhmetafile"` + export mhuse=`anno -list -component 'mhuse' "$mhmetafile"` + export mhfolder=`anno -list -component 'mhfolder' "$mhmetafile"` + export mhmessages=`anno -list -component 'mhmessages' "$mhmetafile"` + export mhannotate=`anno -list -component 'mhannotate' "$mhmetafile"` + send "$@" "$mhdraft" || exit $? + rm -f "$mhmetafile" + exit 0 } delete() { - rmm +draft c - rm $mhmetafile + folder -push "$draftfolder" >/dev/null 2>&1 + rmm "$draftfolder" c + folder -pop >/dev/null 2>&1 + rm "$mhmetafile" } attach() { - get_attachmentheader + header=`mhparam 'Attachment-Header'` while [ -n "$1" ] do if [ ! -f "$1" ] @@ -196,23 +179,23 @@ attach() exit 1 fi file=`get_realpath "$1"` - anno -nodate -append -component $header -text "$file" $mhdraft + anno -nodate -append -component "$header" -text "$file" "$mhdraft" shift done } alist() { - get_attachmentheader - anno -list -number -component $header $mhdraft + header=`mhparam 'Attachment-Header'` + anno -list -number -component "$header" "$mhdraft" } detach() { - get_attachmentheader + header=`mhparam 'Attachment-Header'` while [ -n "$1" ] do - anno -delete -component $header -number "$1" $mhdraft + anno -delete -component "$header" -number "$1" "$mhdraft" if [ $? -ne 0 ] then echo "can't delet attachment $1" 1>&2 @@ -224,14 +207,14 @@ detach() display() { - mhaltmsg=`anno -list -component 'mhaltmsg' $mhmetafile` + mhaltmsg=`anno -list -component 'mhaltmsg' "$mhmetafile"` get_showproc - if [ -n "$mhaltmsg" ] + if [ -z "$mhaltmsg" ] then echo "no altmsg" 1>&2 exit 1 fi - exec $mhshowproc -file $mhaltmsg + exec $mhshowproc -file "$mhaltmsg" } if [ $# -eq 0 ] @@ -240,73 +223,73 @@ then exit fi -command=$1 +command="$1" shift -draftfolder=`mhparam Draft-Folder` -if [ -z "$dratffolder" ] -then - draftfolder="+drafts" -fi -mhdraft=`mhpath $draftfolder c 2>/dev/null` +draftfolder=`mhparam draftfolder` + +mhdraft=`mhpath "$draftfolder" c 2>/dev/null` if [ -z "$mhdraft" ] then - case $command in - -h*) + case "$command" in + -h|-he|-hel|-help) usage $# ;; - -V*) + -V|-Ve|-Ver|-Vers|-Versi|-Versio|-Version) version $# ;; *) - echo "no current message in $draftsfolder" 1>&2 + echo "no current message in $draftfolder" 1>&2 usage 1 ;; esac fi -mhmetafile=$mhdraft.meta -touch $mhmetafile +mhmetafile="$mhdraft".meta +touch "$mhmetafile" -case $command in -e*) +case "$command" in +e|ed|edi|edit) edit "$@" ;; -l*) +l|li|lis|list) [ $# -eq 0 ] || usage 1 list ;; -s*) - send "$@" +s|se|sen|send) + sendfunktion "$@" ;; -del*) +del|dele|delet|delete) [ $# -eq 0 ] || usage 1 delete ;; -di*) +di|dis|disp|displ|displa|display) [ $# -eq 0 ] || usage 1 display ;; -at*) +at|att|atta|attac|attach) attach "$@" ;; -al*) +al|ali|alis|alist) [ $# -eq 0 ] || usage 1 alist ;; -det*) +det|deta|detac|detach) detach "$@" ;; -r*) - refile -nolink -file $mhdraft "$@" +r|re|ref|refi|refil|refile) + refile -file "$mhdraft" "$@" ;; -w*) - whom "$@" $mhdraft +w|wh|who|whom) + whom "$@" "$mhdraft" ;; --h*) +-h|-he|-hel|-help) usage $# ;; --V*) +-V|-Ve|-Ver|-Vers|-Versi|-Versio|-Version) version $# ;; +*) + usage 1 + ;; esac