From: Ian Jackson Date: Mon, 9 Dec 2019 14:49:43 +0000 (+0000) Subject: Syntax: Use &\ for escaping; abolish \& X-Git-Tag: subdirmk/0.3~110 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?p=subdirmk.git;a=commitdiff_plain;h=ad2d261d58a7718898ef7146d37b9c4b8e9083ca;ds=sidebyside Syntax: Use &\ for escaping; abolish \& "\&" causes lots of trouble, including difficulty specifying certain resulting strings. Previously I proposed a scheme using &$@ but this is only useful to provide a way to write &s. The $-doubling regime which will come later wants a way to produce a single literal $, so introduce that now using the same syntax. And &\ feels quite natural to me. Incompatible change. Signed-off-by: Ian Jackson --- diff --git a/README b/README index 67ce6cc..d15a9f4 100644 --- a/README +++ b/README @@ -247,7 +247,9 @@ So pathname syntax is a subset of: '&' [ '^' | '~' ] [ lc | '/' | '.' | '=' ] && => && for convenience in shell runes -\& => & general escaping mechanism + +&\& => & general escaping mechanism +&\$ => $ & thing thing... & &^ thing thing... & @@ -285,7 +287,7 @@ So pathname syntax is a subset of: Notably STUFFSTUFF => STUFFSTUFF - \STUFF => STUFF + STUFF\STUFF => STUFF STUFF:changequote & => set escape back to & &TARGETS_things diff --git a/generate b/generate index ba66f86..dd6df29 100755 --- a/generate +++ b/generate @@ -151,11 +151,11 @@ sub process_input_mk ($$$$$$$$$) { $buffering_output=''; } for (;;) { - unless (s{^(.*?)(\\)?(?=$esc)}{}) { o $_; last; } + unless (s{^(.*?)$esc}{}) { o $_; last; } o $1; - if ($2) { s#^$esc##; o $$esclitr; next; } - s{^$esc}{} or die "$_ ?"; - if (s{^$esc}{}) { o "$$esclitr$$esclitr" } + if (s{^\\$esc}{}) { o "$$esclitr" } + elsif (s{^\\\$}{}) { o '$' } + elsif (s{^$esc}{}) { o "$$esclitr$$esclitr" } elsif (s{^TARGETS(?:_([0-9a-zA-Z_]+))?(?=\W)}{}) { my $t = $1 // 'all'; o target_varname($var_prefix, $t);