Skip to content

Commit dab97ef

Browse files
committed
[Change] Update vendored tlog_lib.sh and tlog to v2.0.4
[Change] Update vendored tlog_lib.sh and tlog to v2.0.4 (shell alias safety, inline comment standards)
1 parent 882120c commit dab97ef

4 files changed

Lines changed: 30 additions & 20 deletions

File tree

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
v2.0.1 | Mar 10 2026:
22

3+
-- Changes --
4+
5+
[Change] Update vendored tlog_lib.sh and tlog to v2.0.4 (shell alias safety,
6+
inline comment standards)
7+
38
-- New Features --
49

510
[New] Compound signature (csig) scanning: multi-pattern boolean logic

CHANGELOG.RELEASE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
v2.0.1 | Mar 10 2026:
22

3+
-- Changes --
4+
5+
[Change] Update vendored tlog_lib.sh and tlog to v2.0.4 (shell alias safety,
6+
inline comment standards)
7+
38
-- New Features --
49

510
[New] Compound signature (csig) scanning: multi-pattern boolean logic

files/internals/tlog

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
2828
export PATH
2929

30-
TLOG_VERSION="2.0.2"
30+
TLOG_VERSION="2.0.4"
3131

3232
# BASERUN: cursor storage directory — sed-replaced at install time
3333
BASERUN="${BASERUN:-/tmp}"
@@ -259,8 +259,8 @@ if [[ ! -f "$_LIB" ]]; then
259259
fi
260260

261261
# Security check: library must be root-owned and not world-writable
262-
_lib_owner=$(stat -L -c '%u' "$_LIB" 2>/dev/null)
263-
_lib_perms=$(stat -L -c '%a' "$_LIB" 2>/dev/null)
262+
_lib_owner=$(stat -L -c '%u' "$_LIB" 2>/dev/null) # stat may fail if lib deleted between checks
263+
_lib_perms=$(stat -L -c '%a' "$_LIB" 2>/dev/null) # stat may fail if lib deleted between checks
264264
_lib_world="${_lib_perms: -1}"
265265
if [[ "$_lib_owner" != "0" ]] || [[ $((_lib_world & 2)) -ne 0 ]]; then
266266
echo "tlog: security check failed on $_LIB (owner=$_lib_owner perms=$_lib_perms)" >&2
@@ -356,7 +356,7 @@ _tlog_cmd_status() {
356356
if [[ $parse_rc -eq 2 ]]; then
357357
# Corrupt cursor: show raw content for diagnosis
358358
local raw_value=""
359-
read -r raw_value < "$cursor_file" 2>/dev/null || true
359+
read -r raw_value < "$cursor_file" 2>/dev/null || true # read exits 1 on EOF; not an error
360360
printf 'raw: %s\n' "$raw_value"
361361
printf 'state: corrupt (would auto-reset on next read)\n'
362362
elif [[ -z "$_tlog_cursor_value" ]]; then
@@ -369,7 +369,7 @@ _tlog_cmd_status() {
369369
# Cursor age
370370
if [[ -f "$cursor_file" ]]; then
371371
local mtime now age_s
372-
mtime=$(stat -c %Y "$cursor_file" 2>/dev/null) || mtime=0
372+
mtime=$(stat -c %Y "$cursor_file" 2>/dev/null) || mtime=0 # stat fails if cursor removed; default to 0
373373
now=$(date +%s)
374374
age_s=$((now - mtime))
375375
if [[ $age_s -ge 86400 ]]; then
@@ -411,7 +411,7 @@ _tlog_cmd_status() {
411411
# Related files
412412
if [[ -f "$BASERUN/${name}.jts" ]]; then
413413
local jts_val
414-
read -r jts_val < "$BASERUN/${name}.jts" 2>/dev/null || true
414+
read -r jts_val < "$BASERUN/${name}.jts" 2>/dev/null || true # read exits 1 on EOF; not an error
415415
printf 'jts: %s\n' "$jts_val"
416416
fi
417417
if [[ -f "$BASERUN/${name}.lock" ]]; then
@@ -440,21 +440,21 @@ _tlog_cmd_reset() {
440440

441441
# Cursor file
442442
if [[ -f "$BASERUN/$name" ]]; then
443-
rm -f "$BASERUN/$name"
443+
command rm -f "$BASERUN/$name"
444444
printf 'removed: %s\n' "$BASERUN/$name"
445445
found=1
446446
fi
447447

448448
# Journal timestamp
449449
if [[ -f "$BASERUN/${name}.jts" ]]; then
450-
rm -f "$BASERUN/${name}.jts"
450+
command rm -f "$BASERUN/${name}.jts"
451451
printf 'removed: %s\n' "$BASERUN/${name}.jts"
452452
found=1
453453
fi
454454

455455
# Lock file
456456
if [[ -f "$BASERUN/${name}.lock" ]]; then
457-
rm -f "$BASERUN/${name}.lock"
457+
command rm -f "$BASERUN/${name}.lock"
458458
printf 'removed: %s\n' "$BASERUN/${name}.lock"
459459
found=1
460460
fi
@@ -463,7 +463,7 @@ _tlog_cmd_reset() {
463463
local tmpfile
464464
for tmpfile in "$BASERUN"/."${name}".??????; do
465465
if [[ -f "$tmpfile" ]]; then
466-
rm -f "$tmpfile"
466+
command rm -f "$tmpfile"
467467
printf 'removed: %s\n' "$tmpfile"
468468
found=1
469469
fi
@@ -472,7 +472,7 @@ _tlog_cmd_reset() {
472472
# Orphaned JTS temp files (mktemp pattern: .NAME.jts.XXXXXX)
473473
for tmpfile in "$BASERUN"/."${name}".jts.??????; do
474474
if [[ -f "$tmpfile" ]]; then
475-
rm -f "$tmpfile"
475+
command rm -f "$tmpfile"
476476
printf 'removed: %s\n' "$tmpfile"
477477
found=1
478478
fi

files/internals/tlog_lib.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
# GNU General Public License for more details.
1818

1919
# Source guard — prevent double-sourcing
20-
[[ -n "${_TLOG_LIB_LOADED:-}" ]] && return 0 2>/dev/null
20+
[[ -n "${_TLOG_LIB_LOADED:-}" ]] && return 0 2>/dev/null # return may fail at top-level; not an error
2121
_TLOG_LIB_LOADED=1
2222

2323
# shellcheck disable=SC2034
24-
TLOG_LIB_VERSION="2.0.3"
24+
TLOG_LIB_VERSION="2.0.4"
2525

2626
# Journal filter registry — consuming projects populate via tlog_journal_register()
2727
# Uses parallel indexed arrays instead of declare -A to avoid scope issues
@@ -56,7 +56,7 @@ _tlog_validate_name() {
5656
_tlog_check_baserun_perms() {
5757
local baserun="$1"
5858
local perms world_bits
59-
perms=$(stat -c '%a' "$baserun" 2>/dev/null) || return 0
59+
perms=$(stat -c '%a' "$baserun" 2>/dev/null) || return 0 # stat fails if dir removed; advisory check
6060
world_bits="${perms: -1}"
6161
if [[ $((world_bits & 2)) -ne 0 ]]; then
6262
echo "tlog: warning: baserun directory '$baserun' is world-writable" >&2
@@ -142,9 +142,9 @@ _tlog_write_cursor() {
142142
}
143143
printf '%s\n' "$formatted" > "$tmp_file"
144144

145-
if ! mv -f "$tmp_file" "$cursor_file"; then
145+
if ! command mv -f "$tmp_file" "$cursor_file"; then
146146
echo "tlog: warning: cursor write failed for $tlog_name (rename)" >&2
147-
rm -f "$tmp_file"
147+
command rm -f "$tmp_file"
148148
return 1
149149
fi
150150

@@ -289,12 +289,12 @@ _tlog_handle_rotation() {
289289

290290
if _tlog_is_compressed "$rtfile"; then
291291
# Try temp-file path: mktemp + decompress + read from temp
292-
tmp_decomp=$(mktemp "$baserun/.${tlog_name}.XXXXXX" 2>/dev/null) || tmp_decomp=""
292+
tmp_decomp=$(mktemp "$baserun/.${tlog_name}.XXXXXX" 2>/dev/null) || tmp_decomp="" # fallback to pipe path on failure
293293
if [[ -n "$tmp_decomp" ]] && _tlog_cat_file "$rtfile" > "$tmp_decomp"; then
294294
rtsize=$(_tlog_get_size "$tmp_decomp" "$mode")
295295
else
296296
# Temp approach failed — clean up and fall back to pipe
297-
[[ -n "$tmp_decomp" ]] && rm -f "$tmp_decomp"
297+
[[ -n "$tmp_decomp" ]] && command rm -f "$tmp_decomp"
298298
echo "tlog: warning: rotation temp file failed for $tlog_name, using pipe fallback" >&2
299299
_tlog_rotation_via_pipe "$rtfile" "$cursor_size" "$mode"
300300
return 0
@@ -314,7 +314,7 @@ _tlog_handle_rotation() {
314314
fi
315315
fi
316316

317-
[[ -n "$tmp_decomp" ]] && rm -f "$tmp_decomp"
317+
[[ -n "$tmp_decomp" ]] && command rm -f "$tmp_decomp"
318318
return 0
319319
}
320320

@@ -331,7 +331,7 @@ tlog_get_file_size() {
331331
return 1
332332
fi
333333

334-
size=$(stat -c %s "$file" 2>/dev/null) || size=$(wc -c < "$file")
334+
size=$(stat -c %s "$file" 2>/dev/null) || size=$(wc -c < "$file") # stat unavailable on some platforms; wc fallback
335335
size="${size## }"
336336
printf '%s' "$size"
337337
}

0 commit comments

Comments
 (0)