ref: 95ef1b2259790e01c9dda588eeabb67e884df834
dir: /add/
#!/bin/rc -e rfork ne fn editmsg{ if(! test -s $msgfile.tmp){ >$msgfile.tmp { echo '#' $synopsis echo '' } edit=1 } if(! ~ $#edit 0){ if(~ $#editor 0){ # store current, run editor, then write change to final cp $msgfile.tmp $msgfile editor=hold } $editor $msgfile.tmp } if(! test -s $msgfile.tmp){ echo 'nothing to add' >[1=2] exit 'message' } # TODO: Check if we have hold as editor, otherwise just cp here cat $msgfile.tmp >> $msgfile } fn gettag{ if(! ~ $#change 0) tag=$change if not tag=`{echo $synopsis | sum | awk '{print $1}'} } fn finish{ #mkdir .task >[2]/dev/null cp $msgfile .task/$tag if(! ~ $#change 0) echo 'Updated: '$tag if not echo 'Created: '$tag } fn sigexit{ if(! ~ $#msgfile 0) rm -f $msgfile if(! ~ $#msgfile.tmp 0) rm -f $msgfile.tmp } flagfmt='c:change change, e:edit'; args='[msg ...]' eval `''{aux/getflags $*} || exec aux/usage msgfile=/tmp/task.$pid if(! ~ $#* 0) synopsis=`{echo $*} if(! ~ $#change 0){ edit=1 if(test -s .task/$change){ if(! ~ $#synopsis 0){ echo '#' $synopsis > $msgfile.tmp tail +2 .task/$change >> $msgfile.tmp } if not cat .task/$change > $msgfile.tmp } if not { echo 'no task found for ' $change >[1=2] exit 'missing' } } @{ flag e + gettag editmsg finish } || echo 'could not write task:' $status >[1=2] exit ''