summaryrefslogtreecommitdiff
path: root/Functions/Calendar/calendar_add
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-01-31 16:53:31 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-01-31 16:53:31 +0000
commit483810a525b138f91dcb11f5864817a6e9ba6699 (patch)
tree9ba7a31bd5566d01148c7db20fadf76476148323 /Functions/Calendar/calendar_add
parenta1476c1ee262e2b75bf12ade0e1225158e835453 (diff)
downloadzsh-483810a525b138f91dcb11f5864817a6e9ba6699.tar.gz
zsh-483810a525b138f91dcb11f5864817a6e9ba6699.zip
23142: calendar enhancements: relative times, recurring events
Diffstat (limited to 'Functions/Calendar/calendar_add')
-rw-r--r--Functions/Calendar/calendar_add31
1 files changed, 25 insertions, 6 deletions
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