about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2024-02-02 10:33:43 -0600
committerCase Duckworth2024-02-02 10:33:43 -0600
commit6d5cbeb41623f32c8dce8e10e1c1539c88b8da89 (patch)
treeb9f570789ade8f7abfadf9a544de1511cf7cdab9
parentMake everything better (diff)
downloadsubtext-6d5cbeb41623f32c8dce8e10e1c1539c88b8da89.tar.gz
subtext-6d5cbeb41623f32c8dce8e10e1c1539c88b8da89.zip
Slight tweak to remove spurious variable
-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"