diff --git a/uscrontab b/uscrontab index 7b71a3e..d316943 100755 --- a/uscrontab +++ b/uscrontab @@ -6,7 +6,7 @@ function display_help() { uecho "$scriptname: lancer une suite de commande en respectant une planification de type cron USAGE - $scriptname [options] [/path/to/crontab] + $scriptname [options] [/path/to/crontab] [var=value...] $scriptname -e [/path/to/crontab] $scriptname -l @@ -326,13 +326,11 @@ elif [ "$action" == "uninstall" ]; then remove_from_crontab "$ctline" && estep "remove_from_crontab $ctline" elif [ "$action" == "run" ]; then - clean_crontab= if [ -n "$crontab" ]; then default_lockfile="/var/run/$scriptname$crontab.lock" else set_usercrontabs usercrontabs ac_set_tmpfile crontab - clean_crontab=1 for usercrontab in "${usercrontabs[@]}"; do echo "# $usercrontab" >>"$crontab" cat "$usercrontab" >>"$crontab" @@ -402,9 +400,10 @@ elif [ "$action" == "run" ]; then function __cterror() { die "$*" } - ctscript="$(ctresolve <"$crontab")" + + __ctscript="$(ctresolve <"$crontab")" ec=0 - edebug "$ctscript" + edebug "$__ctscript" ( # tableau des fichiers de pid en cours. la conséquence est que ce n'est # pas une erreur d'appeler à plusieurs reprises check_pidfile avec le @@ -446,10 +445,21 @@ puis supprimez le cas échéant le fichier $pidfile" array_del __USCRONTAB_PIDFILES "$pidfile" fi } + __ac_forgetall - eval "$ctscript" + # Si des variables sont spécifiées, les initialiser avant de lancer le + # script + for __var in "$@"; do + splitvar "$__var" __name __value + edebug "$__name=$__value" + set_var "$__name" "$__value" + done + eval "$__ctscript" ac_cleanall ); ec=$? + + ac_clean "$crontab" ac_clean "$lockfile" + exit "$ec" fi