last.sh will exit 1 when no file found; handle it in next.sh. meaning um next works in empty dirs

This commit is contained in:
bth 2024-01-22 10:21:53 -08:00
commit cf6ff3349d
6 changed files with 47 additions and 19 deletions

View file

@ -23,8 +23,11 @@
#
# See https://git.bth.moi/bth/um#next
# NOTE the optional $1 arg passed to awk with -v:
NEXTFILE=`$UMBASEPATH/last.sh | awk -f $UMBASEPATH/next.awk -v arg=$1`
# NOTE: handle the exit 1 case of last.sh
LASTFILE=`$UMBASEPATH/last.sh || echo $UMDEFAULTINIT`
# NOTE: the optional $1 arg passed to awk with -v:
NEXTFILE=`echo $LASTFILE | awk -f $UMBASEPATH/next.awk -v arg=$1`
# tag is optional second arg to this script
TAGINSERT='(previous-line) (insert "+ %s\\n") (next-line)'
@ -40,10 +43,12 @@ fi
UMELISP="(progn (find-file \"$NEXTFILE\") (um-journal-header) $UMTAG (message \"creating $NEXTFILE\"))"
# for testing and piping
if [ $UMNEXTECHO = true ]; then
if [ $UMNEXTECHO ]; then
echo $UMELISP
else
# HACK: emacs won't accept piped input as a file name, so we use --eval to open
# the file via find-file.
emacsclient --eval "$UMELISP"
fi
exit 0