Skip to content

Commit a3d9e0a

Browse files
committed
minor fix: handle comma in EPOCHREALTIME parsing
Update timing calculations in `core/build.func` to strip either `.` or `,` from `EPOCHREALTIME` before integer math. This makes network/prefetch latency logging robust across environments where the shell emits a comma decimal separator.
1 parent 806c2e4 commit a3d9e0a

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

core/build.func

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,13 @@ _cs_download() {
181181
local url="${1:?url}"
182182
local t0 code
183183
if [[ ",${dev_mode:-}," == *,net,* ]] && command -v curl >/dev/null 2>&1; then
184-
t0=${EPOCHREALTIME/./}
184+
t0=${EPOCHREALTIME/[.,]/}
185185
local body
186186
body="$(curl -fsSL "${_CS_CURL_RETRY[@]}" -w '
187187
%{http_code}' "$url" 2>/dev/null)"
188188
code="${body##*$'
189189
'}"
190-
_cs_net_log "$code" "$((( ${EPOCHREALTIME/./} - t0 ) / 1000))" "$url"
190+
_cs_net_log "$code" "$((( ${EPOCHREALTIME/[.,]/} - t0 ) / 1000))" "$url"
191191
printf '%s' "${body%$'
192192
'*}"
193193
return 0
@@ -274,7 +274,7 @@ _cs_prefetch_engine() {
274274
done
275275
[[ -z "$dir" ]] && return 1
276276

277-
local _cs_t0=${EPOCHREALTIME/./}
277+
local _cs_t0=${EPOCHREALTIME/[.,]/}
278278
local args=() rel
279279
for rel in "${_CS_ENGINE_FILES[@]}"; do
280280
mkdir -p "${dir}/${rel%/*}" 2>/dev/null || true
@@ -294,7 +294,7 @@ _cs_prefetch_engine() {
294294
missing=$((missing + 1))
295295
fi
296296
done
297-
_cs_net_log "200" "$(( ( ${EPOCHREALTIME/./} - _cs_t0 ) / 1000 ))" "prefetch: ${kept} files, ${missing} missing -> ${dir}"
297+
_cs_net_log "200" "$(( ( ${EPOCHREALTIME/[.,]/} - _cs_t0 ) / 1000 ))" "prefetch: ${kept} files, ${missing} missing -> ${dir}"
298298
if ((kept == 0)); then
299299
rm -rf "$dir" 2>/dev/null
300300
return 1

core/dev-mode.func

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ _dev_step_start() {
154154
[[ "${DEV_MODE_TIMING:-false}" == "true" ]] || return 0
155155
local d
156156
d="$(_dev_timing_dir)" || return 0
157-
printf '%s' "${EPOCHREALTIME/./}" >"${d}/s.$(_dev_step_key "$1")" 2>/dev/null
157+
printf '%s' "${EPOCHREALTIME/[.,]/}" >"${d}/s.$(_dev_step_key "$1")" 2>/dev/null
158158
}
159159

160160
_dev_step_end() {
@@ -165,7 +165,7 @@ _dev_step_end() {
165165
[[ -s "${d}/s.${key}" ]] || return 0
166166
read -r start <"${d}/s.${key}"
167167
rm -f "${d}/s.${key}"
168-
ms=$(((${EPOCHREALTIME/./} - start) / 1000))
168+
ms=$(((${EPOCHREALTIME/[.,]/} - start) / 1000))
169169
printf '%s %s
170170
' "$ms" "$key" >>"${d}/done"
171171
printf ' %s(%s ms)%s' "${DGN:-}" "$ms" "${CL:-}"

0 commit comments

Comments
 (0)