Skip to content

Commit 3569b2f

Browse files
ararslanKristofferC
authored andcommitted
Use POSIX shell instead of Bash in escape_json.sh (#60295)
(cherry picked from commit af36919)
1 parent 6dce22d commit 3569b2f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

contrib/escape_json.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
#!/bin/bash
1+
#!/bin/sh
22
# print arguments escaped as json list elements
33

44
first=true
55
for n in "$@"; do
66
$first && first=false || printf ', '
7-
n="${n//\\/\\\\}"
8-
n="${n//\"/\\\"}"
7+
n=$(printf '%s' "$n" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g')
98
printf '"%s"' "$n"
109
done

0 commit comments

Comments
 (0)