testmark-bash

Storage comments: give the hostile-key rule its reason, and mark where parse commits.

commit c28251e29f7d6645b497c872870318308461a8c7 · parent 57ee9e4527 · browse this tree
Ximianth, 2026-10-23 14:11:05 UTC

diff --git a/lib/testmark/document.bash b/lib/testmark/document.bash
index c1b6518..6424f0f 100644
--- a/lib/testmark/document.bash
+++ b/lib/testmark/document.bash
@@ -12,7 +12,7 @@
 # Names are built only from handles checked against [A-Za-z0-9_]+, and kinds have no "_", so two handles' names never meet.
 # Parse works in locals and commits at its very end, so a failed parse leaves nothing behind.
 # Globals are reached through namerefs; assoc ones are declared first, since a nameref to an undeclared name makes an indexed array.
-# Hunk names are hostile input as keys: arithmetic, `[[ -v ]]`, `unset`, and `printf -v` on an element can run `$(...)` from inside its key.
+# Hunk names come from documents, so they are hostile as keys: on some bash versions, arithmetic, `[[ -v ]]`, `unset`, and `printf -v` on an element run `$(...)` from inside its key.
 # So touch name-keyed elements only as `a[$k]=v`, `"${a[$k]}"`, `"${a[$k]-}"`, `${a[$k]+set}`, and `"${!a[@]}"`.
 
 _testmark_err() {
@@ -101,6 +101,7 @@ _testmark_parse() {
 		return 1
 	}
 
+	# Parsed without error; only now are globals written.
 	declare -gA "_testmark_start_$h" "_testmark_end_$h" "_testmark_info_$h"
 	local -n g_lines=_testmark_lines_$h g_start=_testmark_start_$h g_end=_testmark_end_$h g_info=_testmark_info_$h
 	local -n g_names=_testmark_names_$h g_pid=_testmark_pid_$h