rpdrafts (986B)
1 #!/bin/sh 2 3 usage() { 4 printf "usage. %s [h] [[-e|-d|-v]ids|-l]\n" "$(basename $1)" >&2 5 exit 1 6 } 7 8 doedit=0 9 dodelete=0 10 doview=0 11 12 while getopts "hedvl" opt; 13 do 14 case $opt in 15 e) 16 doedit=1 17 ;; 18 d) 19 dodelete=1 20 ;; 21 v) 22 doview=1 23 ;; 24 l) 25 ;; 26 *) 27 usage $0 28 ;; 29 esac 30 done 31 shift $(expr $OPTIND - 1) 32 33 dfolder=$(rpcfg -v fold_drafts) 34 35 if [ $# -eq 0 ]; 36 then 37 rpinc -qnu | cat > /dev/null 38 id=$(rpids -m $dfolder : | awk -F' ' '{print $1}') 39 if [ "$id" = "0" ]; 40 then 41 echo "No drafts in draft folder." 42 exit 1 43 fi 44 rpscan -m $dfolder : 45 exit $? 46 fi 47 48 if [ $doview -eq 1 ]; 49 then 50 rpview -r -m $dfolder -- "$@" 51 exit $? 52 fi 53 54 if [ $doedit -eq 0 ] && [ $dodelete -eq 0 ]; 55 then 56 rpscan -m $dfolder -- "$@" 57 exit $? 58 fi 59 60 if [ $dodelete -eq 1 ]; 61 then 62 rprm -m $dfolder -- "$@" 63 exit $? 64 fi 65 66 if [ $doedit -eq 1 ]; 67 then 68 id=$(rpids -m $dfolder -- "$@" | awk -F' ' '{print $1}') 69 if [ $? -eq 1 ]; 70 then 71 echo "Please specify a valid message id." 72 exit 1 73 fi 74 75 rpedit -m $dfolder -- $id 76 exit $? 77 fi 78