aboutsummaryrefslogtreecommitdiff
path: root/validators/bash
diff options
context:
space:
mode:
authorAlex Pooley (@zuedev) <zuedev@gmail.com>2026-02-05 16:09:37 +0000
committerAlex Pooley (@zuedev) <zuedev@gmail.com>2026-02-05 16:09:37 +0000
commitf08c9d730ec054fd8f33c6e04ec728ef8ef2e352 (patch)
tree9c289c3df9d1c8e30dfc1626237ffbaafcf2a55f /validators/bash
parentd2fb93dee165c803416278ad3e4b869cd57e4182 (diff)
downloadgitinfo-f08c9d730ec054fd8f33c6e04ec728ef8ef2e352.tar
gitinfo-f08c9d730ec054fd8f33c6e04ec728ef8ef2e352.tar.gz
gitinfo-f08c9d730ec054fd8f33c6e04ec728ef8ef2e352.tar.bz2
gitinfo-f08c9d730ec054fd8f33c6e04ec728ef8ef2e352.tar.xz
gitinfo-f08c9d730ec054fd8f33c6e04ec728ef8ef2e352.zip
handle CRLF line endings and trailing commas in bash
Diffstat (limited to 'validators/bash')
-rw-r--r--validators/bash/validate.sh6
1 files changed, 3 insertions, 3 deletions
diff --git a/validators/bash/validate.sh b/validators/bash/validate.sh
index 55324f1..a34c555 100644
--- a/validators/bash/validate.sh
+++ b/validators/bash/validate.sh
@@ -25,9 +25,9 @@ fi
# Strip JSONC comments using sed
strip_comments() {
- # Remove single-line comments (// ...) and multi-line comments (/* ... */)
- # This is a simplified version - doesn't handle comments inside strings perfectly
- sed -e 's|//.*$||g' -e ':a;s|/\*.*\*/||g;ta' -e '/\/\*/,/\*\//d' "$1"
+ # Remove carriage returns (Windows line endings), single-line comments, and multi-line comments
+ # Also remove trailing commas before } or ] (valid in JSONC, invalid in JSON)
+ cat "$1" | tr -d '\r' | sed -e 's|//.*$||g' -e ':a;s|/\*.*\*/||g;ta' -e '/\/\*/,/\*\//d' | sed -e 's/,\s*}/}/g' -e 's/,\s*]/]/g'
}
# Validate URI format