about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--subtext.awk7
1 files changed, 3 insertions, 4 deletions
diff --git a/subtext.awk b/subtext.awk index 2eedeeb..09ec882 100644 --- a/subtext.awk +++ b/subtext.awk
@@ -11,13 +11,12 @@ BEGIN {
11 dryrun = dryrun ? dryrun : 0 11 dryrun = dryrun ? dryrun : 0
12 sopath = sopath ? sopath : ".:" ENVIRON["HOME"] "/.subtext" 12 sopath = sopath ? sopath : ".:" ENVIRON["HOME"] "/.subtext"
13 shxend = shxend ? shxend : "%%end" 13 shxend = shxend ? shxend : "%%end"
14 ## Kernel 14 ## Shellfix: escape ` and $ in input
15 # Ask sed to do these b/c awk has no capture groups ;_; 15 # Ask sed to do these b/c awk has no capture groups ;_;
16 shellfix = "sed -E" \ 16 shellfix = "sed -E" \
17 " -e 's/`/\\\\`/g'" \ 17 " -e 's/`/\\\\`/g'" \
18 " -e 's/(^|[^\\$])\\$([^\\$]|$)/\\1\\\\$\\2/g'" \ 18 " -e 's/(^|[^\\$])\\$([^\\$]|$)/\\1\\\\$\\2/g'" \
19 " -e 's/(^|[^\\$])\\$(\\$+)([^\\$]|$)/\\1\\2\\3/g'" 19 " -e 's/(^|[^\\$])\\$(\\$+)([^\\$]|$)/\\1\\2\\3/g'"
20 shxquote = " -e 's/^/:/'"
21} 20}
22 21
23/\\$/ { # line continuation 22/\\$/ { # line continuation
@@ -77,8 +76,8 @@ END {
77 print "### body" 76 print "### body"
78 print "body(){ unquote : << \\_ | shexpand" 77 print "body(){ unquote : << \\_ | shexpand"
79 pushpar() 78 pushpar()
80 print body | (shellfix shxquote) 79 print body | (shellfix " -e 's/^/:/'")
81 close(shellfix shxquote) 80 close(shellfix " -e 's/^/:/'")
82 print "_" 81 print "_"
83 print "}" 82 print "}"
84 if (!dryrun) print "body" 83 if (!dryrun) print "body"