Skip to content

Commit 765afb2

Browse files
authored
Harden bash config parse output handling
1 parent 8073e08 commit 765afb2

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

extensions/agent-context/scripts/bash/update-agent-context.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,12 @@ PY
8282
exit 0
8383
fi
8484

85-
mapfile -t _opts_lines <<< "$_raw_opts"
85+
_opts_lines=()
86+
while IFS= read -r _line || [[ -n "$_line" ]]; do
87+
_opts_lines+=("$_line")
88+
done < <(printf '%s\n' "$_raw_opts")
8689
if (( ${#_opts_lines[@]} < 3 )); then
87-
echo "agent-context: malformed config parser output; expected 3 lines, got ${#_opts_lines[@]}; skipping update." >&2
90+
echo "agent-context: malformed config parser output; expected 3 lines (context_file, marker_start, marker_end), got ${#_opts_lines[@]}; skipping update." >&2
8891
exit 0
8992
fi
9093
CONTEXT_FILE="${_opts_lines[0]}"

0 commit comments

Comments
 (0)