diff options
author | Case Duckworth | 2024-01-22 09:44:38 -0600 |
---|---|---|
committer | Case Duckworth | 2024-01-22 09:44:38 -0600 |
commit | 128d8c4bcddf9570da5785ff171e70c97c1a54b5 (patch) | |
tree | ce6111d0697a9adef71665898b5f809d317cf4fd /et | |
parent | Initial commit (diff) | |
download | et-128d8c4bcddf9570da5785ff171e70c97c1a54b5.tar.gz et-128d8c4bcddf9570da5785ff171e70c97c1a54b5.zip |
Update
Diffstat (limited to 'et')
-rwxr-xr-x | et | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/et b/et index 06cbf4c..0e03aa3 100755 --- a/et +++ b/et | |||
@@ -3,15 +3,22 @@ | |||
3 | # usage: et <file> | sh | 3 | # usage: et <file> | sh |
4 | 4 | ||
5 | BEGIN { | 5 | BEGIN { |
6 | xend = xend ? xend : "...xend..." | 6 | xend = xend ? xend : "...end...shexpand..." |
7 | dend = dend ? dend : "...dend..." | 7 | dend = dend ? dend : "...end...document..." |
8 | # We shell out to sed for this because awk doesn't do capture groups ;-; | 8 | # We shell out to sed for this because awk doesn't do capture groups ;-; |
9 | shellfix = "sed -E -e 's/`/\\\\`/g' " \ | 9 | shellfix = "sed -E" \ |
10 | "-e 's/(^|[^\\$])\\$([^\\$]|$)/\\1\\\\$\\2/g' " \ | 10 | " -e 's/`/\\\\`/g'" \ |
11 | "-e 's/(^|[^\\$])\\$(\\$+)([^\\$]|$)/\\1\\2\\3/g'" | 11 | " -e 's/(^|[^\\$])\\$([^\\$]|$)/\\1\\\\$\\2/g'" \ |
12 | " -e 's/(^|[^\\$])\\$(\\$+)([^\\$]|$)/\\1\\2\\3/g'" | ||
13 | htmlfix = "sed -E" \ | ||
14 | " -e 's#([^\\\\]|^)&#\\1\\&#g;'" \ | ||
15 | " -e 's#([^\\\\]|^)<#\\1\\<#g;'" \ | ||
16 | " -e 's#([^\\\\]|^)>#\\1\\>#g;'" \ | ||
17 | " -e 's#\\\\([&<>])#\\1#g;'" | ||
12 | true = 1 ; false = 0 | 18 | true = 1 ; false = 0 |
13 | print "shellexpand()(eval \"$(echo \"cat<<'"xend"'\";cat;echo "xend")\")" | 19 | print "shexpand()(eval \"$(echo \"cat<<'"xend"'\";cat;echo "xend")\")" |
14 | print "shellfix()(" shellfix ")" | 20 | print "shellfix()(" shellfix ")" |
21 | print "htmlfix()(" htmlfix ")" | ||
15 | } | 22 | } |
16 | 23 | ||
17 | end[endn] && $0 == end[endn] { | 24 | end[endn] && $0 == end[endn] { |
@@ -32,7 +39,7 @@ end[endn] && $0 == end[endn] { | |||
32 | docp = !docp | 39 | docp = !docp |
33 | docend = $2 ? $2 : dend | 40 | docend = $2 ? $2 : dend |
34 | if (docp) | 41 | if (docp) |
35 | print "shellexpand<<" docend | 42 | print "shexpand<<" docend |
36 | else | 43 | else |
37 | print docend "\n" | 44 | print docend "\n" |
38 | next | 45 | next |