We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 92ab34b + 9f6a357 commit 3a1bc49Copy full SHA for 3a1bc49
scripts/jq-template.awk
@@ -3,18 +3,13 @@
3
# see https://github.com/docker-library/php or https://github.com/docker-library/golang for examples of usage ("apply-templates.sh")
4
5
# escape an arbitrary string for passing back to jq as program input
6
-function jq_escape(str, # parameters
7
- prog, e, out) # locals
8
-{
9
- prog = "jq --raw-input --slurp ."
10
- printf "%s", str |& prog
11
- close(prog, "to")
12
- prog |& getline out
13
- e = close(prog)
14
- if (e != 0) {
15
- exit(e)
16
- }
17
- return out
+function jq_escape(str) {
+ gsub(/\\/, "\\\\", str)
+ gsub(/\n/, "\\n", str)
+ gsub(/\r/, "\\r", str)
+ gsub(/\t/, "\\t", str)
+ gsub(/"/, "\\\"", str)
+ return "\"" str "\""
18
}
19
20
# return the number of times needle appears in haystack
0 commit comments