From 6030c8b06dc46efa338439f9ba915fc0f81460cd Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 8 Jun 2026 12:37:57 +0000 Subject: [PATCH] tools: fix fbq-add-source.sh failing to list sources with inline yaml comments yq stops mid-array when it encounters inline comments like '# grant per-user only'. Strip comments via sed before piping to yq in list_sources, source_exists, and before in-place edits. https://claude.ai/code/session_014CCYqVwW6d6f5dw1qRokYt --- tools/fbq-add-source.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/fbq-add-source.sh b/tools/fbq-add-source.sh index 3824e4a..6d08b50 100644 --- a/tools/fbq-add-source.sh +++ b/tools/fbq-add-source.sh @@ -107,13 +107,16 @@ backup() { # ── Check if a source path already exists in config ────────────────────────── source_exists() { local config="$1" path="$2" - yq e '.server.sources[].path' "$config" 2>/dev/null | grep -qxF "$path" + sed 's/[[:space:]]*#.*$//' "$config" \ + | yq e '.server.sources[].path' - 2>/dev/null \ + | grep -qxF "$path" } # ── List existing sources ───────────────────────────────────────────────────── list_sources() { local config="$1" - yq e '.server.sources[] | .path' "$config" 2>/dev/null + # Strip inline comments before parsing — yq can mishandle them mid-array + sed 's/[[:space:]]*#.*$//' "$config" | yq e '.server.sources[] | .path' - 2>/dev/null } # ── Restart the container ───────────────────────────────────────────────────── @@ -179,6 +182,9 @@ cmd_add() { [[ "${read_only_bool_raw,,}" == "y" ]] && read_only_bool="true" backup "$config" + # Strip inline comments first so yq edits cleanly + local tmp; tmp=$(mktemp) + sed 's/[[:space:]]*#.*$//' "$config" > "$tmp" && mv "$tmp" "$config" yq e -i ".server.sources += [{ \"path\": \"${container_path}\", \"name\": \"${source_name}\",