maj des inclusions

This commit is contained in:
Jephté Clain 2014-08-28 10:14:35 +04:00
parent fcf60b2bca
commit f200c7ec66
2 changed files with 119 additions and 39 deletions

View File

@ -108,6 +108,12 @@ function nef() {
"$@" | sed '/^$/d'
}
function tolower() {
echo ${*,,}
}
function toupper() {
echo ${*^^}
}
function isnum() {
[ ${#1} -gt 0 ] || return 1
local v="$1"
@ -1644,9 +1650,9 @@ function array_deli(dest, i, l) {
}
delete dest[l]
}
function array_del(dest, value, i) {
function array_del(dest, value, ignoreCase, i) {
do {
i = key_index(value, dest)
i = key_index(value, dest, ignoreCase)
if (i != 0) array_deli(dest, i)
} while (i != 0)
}
@ -2273,8 +2279,7 @@ function __po_process_options() {
function __genparse_shortopt() {
local LC_COLLATE=C
local shortopt="${1//[^A-Z]}"
shortopt="${shortopt:0:1}"
shortopt="${shortopt,,}"
shortopt="$(tolower "${shortopt:0:1}")"
[ -n "$shortopt" ] && echo "$shortopt"
}
HELP_DESC=
@ -2289,7 +2294,7 @@ function genparse() {
if [[ "$var" == *=* ]]; then
splitvar "$var" name value
shortopt="$(__genparse_shortopt "$name")"
option="${name,,}"
option="$(tolower "$name")"
name="${option//-/_}"
array_add names "$name"
array_add descs "${shortopt:+-$shortopt, }--$option VALUE"
@ -2298,7 +2303,7 @@ function genparse() {
else
name="$var"
shortopt="$(__genparse_shortopt "$name")"
option="${name,,}"
option="$(tolower "$name")"
name="${option//-/_}"
array_add names "$name"
array_add descs "${shortopt:+-$shortopt, }--$option"
@ -3594,6 +3599,22 @@ if check_sysinfos -s macosx; then
function _nl2crlf() { _nl2lf | awk '{ print $0 "\r" }'; }
function _nl2cr() { _nl2lf | awk 'BEGIN { ORS="" } { print $0 "\r" }'; }
function sedi() { sed -i '' "$@"; }
function tolower() { tr A-Z a-z <<<"$*"; }
function toupper() { tr a-z A-Z <<<"$*"; }
function is_yes() {
case "$(tolower "$1")" in
o|oui|y|yes|v|vrai|t|true|on) return 0;;
esac
isnum "$1" && [ "$1" -ne 0 ] && return 0
return 1
}
function is_no() {
case "$(tolower "$1")" in
n|non|no|f|faux|false|off) return 0;;
esac
isnum "$1" && [ "$1" -eq 0 ] && return 0
return 1
}
function __po_check_options() {
local -a options args

121
ucrontab
View File

@ -196,6 +196,12 @@ function nef() {
"$@" | sed '/^$/d'
}
function tolower() {
echo ${*,,}
}
function toupper() {
echo ${*^^}
}
function isnum() {
[ ${#1} -gt 0 ] || return 1
local v="$1"
@ -1732,9 +1738,9 @@ function array_deli(dest, i, l) {
}
delete dest[l]
}
function array_del(dest, value, i) {
function array_del(dest, value, ignoreCase, i) {
do {
i = key_index(value, dest)
i = key_index(value, dest, ignoreCase)
if (i != 0) array_deli(dest, i)
} while (i != 0)
}
@ -2361,8 +2367,7 @@ function __po_process_options() {
function __genparse_shortopt() {
local LC_COLLATE=C
local shortopt="${1//[^A-Z]}"
shortopt="${shortopt:0:1}"
shortopt="${shortopt,,}"
shortopt="$(tolower "${shortopt:0:1}")"
[ -n "$shortopt" ] && echo "$shortopt"
}
HELP_DESC=
@ -2377,7 +2382,7 @@ function genparse() {
if [[ "$var" == *=* ]]; then
splitvar "$var" name value
shortopt="$(__genparse_shortopt "$name")"
option="${name,,}"
option="$(tolower "$name")"
name="${option//-/_}"
array_add names "$name"
array_add descs "${shortopt:+-$shortopt, }--$option VALUE"
@ -2386,7 +2391,7 @@ function genparse() {
else
name="$var"
shortopt="$(__genparse_shortopt "$name")"
option="${name,,}"
option="$(tolower "$name")"
name="${option//-/_}"
array_add names "$name"
array_add descs "${shortopt:+-$shortopt, }--$option"
@ -3882,6 +3887,22 @@ if check_sysinfos -s macosx; then
function _nl2crlf() { _nl2lf | awk '{ print $0 "\r" }'; }
function _nl2cr() { _nl2lf | awk 'BEGIN { ORS="" } { print $0 "\r" }'; }
function sedi() { sed -i '' "$@"; }
function tolower() { tr A-Z a-z <<<"$*"; }
function toupper() { tr a-z A-Z <<<"$*"; }
function is_yes() {
case "$(tolower "$1")" in
o|oui|y|yes|v|vrai|t|true|on) return 0;;
esac
isnum "$1" && [ "$1" -ne 0 ] && return 0
return 1
}
function is_no() {
case "$(tolower "$1")" in
n|non|no|f|faux|false|off) return 0;;
esac
isnum "$1" && [ "$1" -eq 0 ] && return 0
return 1
}
function __po_check_options() {
local -a options args
@ -4269,11 +4290,16 @@ function enable_in_crontab() {
function ctnow() {
date +"%-M %-H %-d %-m %u"
}
__CTRESOLVE_CTNOW=""
function ctresolve() {
local -a ctnow
if [ -n "$__CTRESOLVE_CTNOW" ]; then
eval "ctnow=($__CTRESOLVE_CTNOW)"
else
eval "ctnow=($(ctnow))"
fi
filter_conf | awkrun -f ctnow[@] '
function ctmatch(ctval, ref, parts, part, i, j, start, end, step, ok) {
function ctmatch_one(ctval, ref, parts, part, i, j, start, end, step, ok) {
ok = 0
split(ctval, parts, /,/)
for(i = 1; i <= length(parts); i++) {
@ -4302,17 +4328,41 @@ function ctmatch(ctval, ref, parts, part, i, j, start, end, step, o
}
return ok
}
function ctmatch_all(M, H, dom, mon, dow, refM, refH, refdom, refmon, refdow, Mok, Hok, domok, monok, dowok) {
gsub(/\*/, "0-59", M)
Mok = ctmatch_one(M, refM)
gsub(/\*/, "0-23", H)
Hok = ctmatch_one(H, refH)
gsub(/\*/, "1-31", dom)
domok = ctmatch_one(dom, refdom)
gsub(/\*/, "1-12", mon)
monok = ctmatch_one(mon, refmon)
gsub(/\*/, "1-7", dow)
dowok = ctmatch_one(dow, refdow)
return Mok && Hok && monok && (domok || dowok)
}
function print_cmd(cmd) {
print "__ctexec " quote_value(cmd)
}
BEGIN {
refM = ctnow[1]; refH = ctnow[2]; refdom = ctnow[3]; refmon = ctnow[4]; refdow = ctnow[5]
ctref = refM " " refH " " refdom " " refmon " " refdow
print "## now: " ctref
match_ctline = 0
ctline_run = 0
ctline_run_one_match = 0
match_indented = 0
}
/^(export[ \t]+)?[a-zA-Z_][a-zA-Z0-9_]*[-+%#?]=/ {
ctline_run = 0; ctline_run_one_match = 0; match_indented = 0
match($0, /^(export[ \t]+)?([a-zA-Z_][a-zA-Z0-9_]*)([-+%#?])=(.*)$/, parts)
name = parts[2]
type = parts[3]
@ -4330,11 +4380,15 @@ BEGIN {
next
}
/^(export[ \t]+)?[a-zA-Z_][a-zA-Z0-9_]*=/ {
ctline_run = 0; ctline_run_one_match = 0; match_indented = 0
sub(/^export[ \t]+/, "", $0)
print "export " $0
next
}
/^\$.+/ {
ctline_run = 0; ctline_run_one_match = 0; match_indented = 0
if ($0 ~ /^\$\{([ \t]*(#.*)?)?$/) {
getline
while ($0 !~ /^\$\}([ \t]*(#.*)?)?$/) {
@ -4347,45 +4401,50 @@ BEGIN {
}
next
}
/^[ \t]*[-0-9/*,]+[ ]*[-0-9/*,]+[ ]*[-0-9/*,]+[ ]*[-0-9/*,]+[ ]*[-0-9/*,]+/ {
M = $1; H = $2; dom = $3; mon = $4; dow = $5
sub(/^[ ]*[^ ]+[ ]+[^ ]+[ ]+[^ ]+[ ]+[^ ]+[ ]+[^ ]+[ ]*/, "", $0)
if (!match_ctline) match_indented = 0
/^[ \t]*[-0-9/*,]+[ ]*[-0-9/*,]+[ ]*[-0-9/*,]+[ ]*[-0-9/*,]+[ ]*[-0-9/*,]+/ {
match_indented = 0
M = $1; H = $2; dom = $3; mon = $4; dow = $5
ctline = M " " H " " dom " " mon " " dow
gsub(/\*/, "0-59", M)
Mok = ctmatch(M, refM)
sub(/^[ \t]*[^ ]+[ ]+[^ ]+[ ]+[^ ]+[ ]+[^ ]+[ ]+[^ ]+[ ]*/, "", $0)
cmd = $0
gsub(/\*/, "0-23", H)
Hok = ctmatch(H, refH)
match_cur = ctmatch_all(M, H, dom, mon, dow, refM, refH, refdom, refmon, refdow)
if (match_cur) print "## match: " ctline
gsub(/\*/, "1-31", dom)
domok = ctmatch(dom, refdom)
if (cmd == "") {
ctline_run = 1
if (match_cur) ctline_run_one_match = 1
if (ctline_run_one_match) match_indented = 1
gsub(/\*/, "1-12", mon)
monok = ctmatch(mon, refmon)
gsub(/\*/, "1-7", dow)
dowok = ctmatch(dow, refdow)
if (Mok && Hok && monok && (domok || dowok)) {
print "##matches: " ctline
match_ctline = 1
} else {
if (ctline_run && match_cur) ctline_run_one_match = 1
if (ctline_run && ctline_run_one_match) {
print_cmd(cmd)
match_indented = 1
}
if (match_ctline && $0 != "") {
print "__ctexec " quote_value($0)
match_ctline = 0
if (!ctline_run && match_cur) {
print_cmd(cmd)
match_indented = 1
}
ctline_run = 0
ctline_run_one_match = 0
}
next
}
/^[ \t]+/ {
ctline_run = 0; ctline_run_one_match = 0
if (match_indented) {
sub(/^[ \t]+/, "", $0)
print "__ctexec " quote_value($0)
print_cmd($0)
}
next
}
{