From 9178f4c13177c6436d08182e1649d8476b4c3b8a Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 29 Dec 2019 14:17:00 +0000 Subject: [PATCH] Syntax: Expand &$( and &$NN to use ${ } rather than $( ) And now document the use of $&+ for recipes. Signed-off-by: Ian Jackson --- README | 8 ++++++-- generate | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README b/README index 0b84a0e..14cc542 100644 --- a/README +++ b/README @@ -205,6 +205,10 @@ Dollar doubling and macro assistance &$- Stops dollar-doubling Both are idempotent and local to the file or context. +This is useful both for make macrology involving $(eval ...), and +possibly for helping write complicated recipes involving shell +variables, inline Perl code, etc. + Sometimes we will show $'s being doubled inside another construct. This means the content of the construct is $-doubled: $-doubling is locally enabled, and restored afterwards. @@ -233,8 +237,8 @@ $ => $$ including $'s produced by other &-expansions not mentioned here &\$ => $ -&$( => $( -&$NN => $(NN) where N are digits +&$( => ${ (expands to { } so it is useable for shell too) +&$NN => ${NN} where N are digits A few contexts do not support $-doubling, such as directive arguments or places where this might imply $-quadrupling. (There is no way to diff --git a/generate b/generate index f571fa1..f91cba8 100755 --- a/generate +++ b/generate @@ -361,10 +361,10 @@ sub process_input_mk ($$$$) { elsif (s{^\$\-}{}) { $ddbl=undef; } elsif (s{^\$\+}{}) { $ddbl=1; } elsif (s{^\$\(}{}) { - ddbl_only($&); oud "\$("; + ddbl_only($&); oud "\${"; $note_varref->($2,!!$1) if m{^($esc)?([^()\$]+\))}; } - elsif (s{^\$(\d+)}{}) { ddbl_only($&); oud "\$($1)"; } + elsif (s{^\$(\d+)}{}) { ddbl_only($&); oud "\${$1}"; } elsif (s{^\$\{}{}) { err 'macro invocation cannot be re-$-doubled' if $ddbl; od '${eval ${call '; -- 2.30.2