]> git.plutz.net Git - webpoll/commitdiff
avoid octal interpretation in printf %i
authorPaul Hänsch <paul@plutz.net>
Tue, 19 May 2026 04:20:07 +0000 (06:20 +0200)
committerPaul Hänsch <paul@plutz.net>
Tue, 19 May 2026 04:20:07 +0000 (06:20 +0200)
newdate.sh

index fc25ca5a0e97c4503496585a8da59a5fbcd67865..84c1d217ae88d8ccc51a32c6ac9fd1fbe56c577f 100755 (executable)
@@ -94,8 +94,8 @@ if [ "$REQUEST_METHOD" = POST ]; then
       todend="$(POST todend "$todcount")"
       [ "${todstart%:??}" -lt "${todend%:??}" -o "${todstart%:??}" -eq "${todend%:??}" -a "${todstart#*:}" -lt "${todend#*:}" ] \
       2>&- \
-      && { printf '%02i:%02i-%02i:%02i\n' "${todstart%:??}" "${todstart#*:}" "${todend%:??}" "${todend#*:}"; }\
-      || { [ "${todstart%:??}" -ge 0 -a  "${todstart#*:}" -ge 0 ] 2>&- && printf '%02i:%02i-\n' "${todstart%:??}" "${todstart#*:}"; }
+      && { printf '%02.0f:%02.0f-%02.0f:%02.0f\n' "${todstart%:??}" "${todstart#*:}" "${todend%:??}" "${todend#*:}"; }\
+      || { [ "${todstart%:??}" -ge 0 -a  "${todstart#*:}" -ge 0 ] 2>&- && printf '%02.0f:%02.0f-\n' "${todstart%:??}" "${todstart#*:}"; }
     done |grep -xE '^([01][0-9]|2[0-3]):([0-5][0-9])-(([01][0-9]|2[0-3]):([0-5][0-9]))?$' |sort -u
   )"
   [ "$addtime" = global ] && DBM "$file" append todall "${BR}-"
@@ -110,8 +110,8 @@ if [ "$REQUEST_METHOD" = POST ]; then
         todend="$(POST "todend_${date}" "$todcount")"
         [ "${todstart%:??}" -lt "${todend%:??}" -o "${todstart%:??}" -eq "${todend%:??}" -a "${todstart#*:}" -lt "${todend#*:}" ] \
         2>&- \
-        && { printf '%02i:%02i-%02i:%02i\n' "${todstart%:??}" "${todstart#*:}" "${todend%:??}" "${todend#*:}"; }\
-        || { [ "${todstart%:??}" -ge 0 -a  "${todstart#*:}" -ge 0 ] 2>&- && printf '%02i:%02i-\n' $(dec ${todstart%:??} ${todstart#*:}); }
+        && { printf '%02.0f:%02.0f-%02.0f:%02.0f\n' "${todstart%:??}" "${todstart#*:}" "${todend%:??}" "${todend#*:}"; }\
+        || { [ "${todstart%:??}" -ge 0 -a  "${todstart#*:}" -ge 0 ] 2>&- && printf '%02.0f:%02.0f-\n' $(dec ${todstart%:??} ${todstart#*:}); }
       done |grep -xE '^([01][0-9]|2[0-3]):([0-5][0-9])-(([01][0-9]|2[0-3]):([0-5][0-9]))?$' |sort -u
     )"
     [ "$addtime" = "$date" ] && DBM "$file" append "tod_${date}" "${BR}-"