From 5f74960e17f8862cbe9919071d2c8149bc27bea8 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 6 Feb 2024 22:11:51 -0600 Subject: Fix quoting (sort of) Honestly shell quoting is such a bugbear that I'm not sure how to solve it. It might just be part of having a shell pass through that quoting will be weird. --- subtext.awk | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/subtext.awk b/subtext.awk index 07dfb76..881ebe2 100644 --- a/subtext.awk +++ b/subtext.awk @@ -59,11 +59,6 @@ end[endn] && $0 == end[endn] { $0 = substr($0, 3, RSTART?RSTART-3:length) par = par (par?"\n":"") \ "$$(" ($1 ? $1 " " shquote(2) : "") " << " end[endn] - # par = par (par?"\n":"") \ - # "$$(unquote + << .." \ - # (length>2 ? " | " substr($1,3) " " shquote(2) : "") \ - # slurp("..") \ - # "..\n)" next } @@ -122,14 +117,15 @@ function shquote(begin, end, quoted, out) { if (!begin) begin = 1 if (!end) end = NF for (i=begin; i<=NF; i++) { + if ($i ~ /"/) quoted = 1 if ($i ~ /^\$/) { quoted = 1 - out = out (out?" ":"") "\"" $i - continue + $i = "\"" $i } - if (($i ~ /\)$/) && quoted) { + if ((($i ~ /\)$/) || ($i ~ /"$/)) && quoted) { quoted = 0 - out = out (out?" ":"") $i "\"" + if ($i !~ /"$/) $i = $i "\"" + out = out (out?" ":"") $i continue } if (!quoted) { -- cgit 1.4.1-21-gabe81