diff --git a/scripts/onboard/lib/common.sh b/scripts/onboard/lib/common.sh index fa51cbb..7345698 100644 --- a/scripts/onboard/lib/common.sh +++ b/scripts/onboard/lib/common.sh @@ -65,8 +65,15 @@ yaml_get() { yq -r ".${key} // empty" "$file" 2>/dev/null else # fallback: extract last segment of key, match " key: value" + # Strip inline YAML comment (space(s)+'#'+rest) and surrounding whitespace. + # Pattern uses \+ (BRE one-or-more) so a bare '#' inside a value is preserved. local leaf="${key##*.}" - grep -E "^\s*${leaf}:" "$file" | head -1 | sed 's/.*: *//' | tr -d '"' | tr -d "'" + grep -E "^\s*${leaf}:" "$file" | head -1 \ + | sed -e 's/^[[:space:]]*[^:]*:[[:space:]]*//' \ + -e 's/[[:space:]]\+#.*$//' \ + -e 's/^[[:space:]]*//' \ + -e 's/[[:space:]]*$//' \ + | tr -d '"' | tr -d "'" fi }