Skip to content

Commit 634f645

Browse files
committed
test alternative escape logic 3
1 parent cf3210f commit 634f645

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

script/create-release-vdf.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ else
2222
fi
2323

2424
# Check mod description
25-
if [ -f "$3" ]
26-
then
27-
description=$(<"$3" sed -e 's/\\/\\\\/g' -e 's/"/\\"/g')
25+
if [ -f "$3" ]; then
26+
description=$(sed \
27+
-e ':a;N;$!ba' \ # slurp entire file
28+
-e 's/\\/\\\\/g' \ # escape backslashes
29+
-e 's/"/\\"/g' \ # escape double-quotes
30+
-e 's/\n/\\n/g' \ # turn real newlines into \n
31+
"$3")
32+
printf '\t"description" "%s"\n' "$description" >> workshop.vdf
2833
fi
2934

3035
# Clean up old file
@@ -49,6 +54,6 @@ then
4954
printf '\t"description" "%s"' "$description" >> workshop.vdf
5055
printf '\n' >> workshop.vdf
5156
fi
52-
printf '}' >> workshop.vdf
57+
printf '}\n' >> workshop.vdf
5358

5459
cat workshop.vdf

0 commit comments

Comments
 (0)