In the code below, two of the right brackets , a square ']' bracket on
line 15 (2nd one from right) , and a curly one on line 34 (only bracket
on line)
are hilighted in red indicating no match...
but putting your cursor over them shows its matching pair
(and the program works fine as it is...so am pretty sure they are not
unbalanced...)
Any ideas why the red hilighting?
TIA..
---------------------------------------------------------------------------------
#!/bin/bash -eu
# 10 elements backup levels:
# 0, 1, 2, 3, 4, 5, 6,7,8,9
declare -r backup_base="/backups/Ishtar"
# must keep levels 0 for beginning of a month and
declare -ai diffs=(0 1 1 1 2 2 3 3 4 4)
declare -xi start=2
typeset -xri MaxLevel=9
function weeks_to_keep_level {
local -i level=${1:?} offset=${2:-$start}
((level<MaxLevel)) && offset=$(weeks_to_keep_level $[level+1] $offset)
echo $[offset+${diffs[$[MaxLevel-level]]}]
}
function dumps_gt_weeks {
local -i days=$[${1:?}*7];local -a files
readarray files < <(\
find . -type f -name "*-$l-*.dump" -mtime +$days -print)
echo "${files[@]:-""}"
}
function display_curve {
local ln1="Level: "
local ln2="Keep4: "
local -i l
for ((l = MaxLevel; l>=0; --l)) {
printf -v ln1 "%s %2d" "$ln1" "$l"
printf -v ln2 "%s %2d" "$ln2" "$(weeks_to_keep_level $l)"
}
echo -e "$ln1\n$ln2"
}
function split2lns { printf "%s\n" $@ ; }
display_curve
cd "$backup_base" || {
echo "cd to '$backup_base' failed" >&2
exit 1
}
echo "Working from backup base '$backup_base'"
declare -i level weeks
for ((l=9; l>=0; --l)) {
weeks=$(weeks_to_keep_level $l)
echo -n "level $l >= $weeks weeks: "
files=($(dumps_gt_weeks $weeks))
if ((${#files[@]})); then
echo ""
split2lns "${files[@]:-""}" | xargs --no-run-if-empty du -sh
|hsort -s
echo rm above files?
ans=""
read ans
if [[ $ans == y ]]; then
split2lns "${files[@]}"|dumps_gt_weeks $weeks |\
xargs --no-run-if-empty rm -f
fi
else
echo "(None Found)"
fi
}
# vim: ts=2 sw=2
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php