From 483810a525b138f91dcb11f5864817a6e9ba6699 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 31 Jan 2007 16:53:31 +0000 Subject: 23142: calendar enhancements: relative times, recurring events --- Functions/Calendar/calendar_add | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'Functions/Calendar/calendar_add') diff --git a/Functions/Calendar/calendar_add b/Functions/Calendar/calendar_add index f7f60e136..8e6eca8b6 100644 --- a/Functions/Calendar/calendar_add +++ b/Functions/Calendar/calendar_add @@ -10,12 +10,29 @@ emulate -L zsh setopt extendedglob -local calendar newfile REPLY lastline +local calendar newfile REPLY lastline opt local -a calendar_entries lockfiles -integer newdate done rstat +integer newdate done rstat nolock nobackup autoload -U calendar_{read,lockfiles,scandate} +while getopts "BL" opt; do + case $opt in + (B) + nobackup=1 + ;; + + (L) + nolock=1 + ;; + + (*) + return 1 + ;; + esac +done +shift $(( OPTIND - 1 )) + # Read the calendar file from the calendar-file style zstyle -s ':datetime:calendar_add:' calendar-file calendar || calendar=~/calendar @@ -31,7 +48,7 @@ fi # start of block for following always to clear up lockfiles. { - calendar_lockfiles $calendar || return 1 + (( nolock )) || calendar_lockfiles $calendar || return 1 if [[ -f $calendar ]]; then calendar_read $calendar @@ -48,10 +65,12 @@ fi done (( done )) || print -r -- "$*" } >$newfile - if ! mv $calendar $calendar.old; then - print "Couldn't back up $calendar to $calendar.old. + if (( ! nobackup )); then + if ! mv $calendar $calendar.old; then + print "Couldn't back up $calendar to $calendar.old. New calendar left in $newfile." >&2 - (( rstat = 1 )) + (( rstat = 1 )) + fi fi else print -r -- $line >$newfile -- cgit 1.4.1