Skip to content

A complete AI agency at your fingertips - From frontend wizards to Reddit community ninjas, from whimsy injectors to reality checkers. Each agent is a specialized expert with personality, processes, and proven deliverables.

Shell

fix(lib): get_field strips a quoted YAML scalar's outer quotes so quoted sources don't double-wrap (#826)

Michael Sitarzewski3febe026c182
diff --git a/scripts/lib.sh b/scripts/lib.sh
index 270388a9..e1eeba8a 100755
--- a/scripts/lib.sh
+++ b/scripts/lib.sh
@@ -21,7 +21,16 @@ get_field() {
local field="$1" file="$2"
awk -v f="$field" '
/^---$/ { fm++; next }
- fm == 1 && $0 ~ "^" f ": " { sub("^" f ": ", ""); print; exit }
+ fm == 1 && $0 ~ "^" f ": " {
+ sub("^" f ": ", "")
+ # A quoted YAML scalar carries its quotes as delimiters, not content.
+ # Strip one matching outer pair and unescape, so a quoted source value
+ # never double-wraps when a converter re-quotes it (\047 is a literal
+ # apostrophe; this program sits inside shell single quotes).
+ if ($0 ~ /^".*"$/) { $0 = substr($0, 2, length($0) - 2); gsub(/\\"/, "\"", $0); gsub(/\\\\/, "\\", $0) }
+ else if ($0 ~ /^\047.*\047$/) { $0 = substr($0, 2, length($0) - 2); gsub(/\047\047/, "\047", $0) }
+ print; exit
+ }
' "$file"
}