--- trunk/mage/usr/lib/mage/mage4.functions.sh 2012/02/16 12:00:59 1690 +++ trunk/mage/usr/lib/mage/mage4.functions.sh 2012/02/18 13:48:34 1758 @@ -1870,18 +1870,35 @@ local filename="${file##*/}" local count local output + local oldprotected local i + local x - declare -i count=0 + # hack; do not honor a global set IFS like '§' + local IFS + + count=0 # check if there are already protected files - for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" | + for oldprotected in $(find ${dirname} -iname "._cfg????_${filename}" | sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | sort -t'%' -k3 -k2 | cut -f1 -d'%') do - count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::") + count="$(echo ${oldprotected} | sed 's:.*\/._cfg\(.*\)_.*:\1:')" done - (( count ++ )) + + # dirty hack to convert 0001 -> 1; 0120 -> 120 etc + x="${#count}" + for (( i=0; i