Permalink
Browse files

convert zcron lib into zsh style autoloads

  • Loading branch information...
1 parent 89c3290 commit 13a10780d3205c4b953d237cdb9a1177da9c8ca4 @rsanders committed Feb 13, 2012
@@ -15,3 +15,5 @@ add_periodic() {
PERIOD_FUNCS[$func]=$func
done
}
+
+add_periodic $*
@@ -1,8 +1,7 @@
#!/bin/zsh
-delete_periodic() {
for func in $*; do
- delete "PERIOD_FUNCS[$func]"
+ unset "PERIOD_FUNCS[$func]"
done
-}
+
@@ -1,7 +1,6 @@
#!/bin/zsh
-function run_cron_funcs() {
emulate -L zsh
local func last dir seconds key period
@@ -19,5 +18,5 @@ function run_cron_funcs() {
$func
fi
done
-}
+
@@ -1,7 +1,5 @@
#!/bin/zsh
-
-function run_periodic_dir() {
emulate -L zsh
local last dir seconds key
@@ -19,4 +17,3 @@ function run_periodic_dir() {
ZCRON_TIMESTAMPS[$key]=$SECONDS
zsourcedir $ZCONFIGDIR/$dir
fi
-}
@@ -1,6 +1,5 @@
#!/bin/zsh
-function zcron {
emulate -L zsh
setopt typeset_silent
@@ -47,4 +46,3 @@ function zcron {
*) echo -E "Unknown cron command: $opt" >&2; return 1;;
esac
-}
@@ -1,7 +1,6 @@
#!/bin/zsh
-zcron_add() {
local period=$1 func=$2
ZCRON_FUNCTIONS[$func]=$period
-}
+
@@ -1,12 +1,10 @@
#!/bin/zsh
-
-zcron_delete() {
local func=$1
#local OLDIFS="$IFS"
#IFS="\0"
unset "ZCRON_FUNCTIONS[$func]"
unset "ZCRON_TIMESTAMPS[$func]"
#IFS="$OLDIFS"
-}
+
@@ -1,12 +1,11 @@
#!/bin/zsh
-zcron_list() {
local func period
#local OLDIFS="$IFS"
#IFS="\0"
for func in ${(k)ZCRON_FUNCTIONS}; do
echo $ZCRON_FUNCTIONS[$func] - $func
done
#IFS="$OLDIFS"
-}
+
@@ -3,7 +3,6 @@
#
# not currently used; the recursive add crashes zsh for me
#
-zcron_runner() {
run_cron_funcs
sched +30 zcron_runner
}
@@ -1,7 +1,6 @@
#!/bin/zsh
-function zperiodic_function() {
for func in ${(k)PERIOD_FUNCS}
do
$func
@@ -11,5 +10,5 @@ function zperiodic_function() {
run_periodic_dir hourly 3600
run_periodic_dir daily 86400
run_periodic_dir weekly 604800
-}
+
@@ -23,7 +23,7 @@ typeset -A -H -g ZCRON_FUNCTIONS
local _zfile
for _zfile in $libdir/functions/*; do
- autoload -Uk ${_zfile:t}
+ autoload -U ${_zfile:t}
done
typeset -g -a periodic_functions

0 comments on commit 13a1078

Please sign in to comment.