chiark / gitweb /
Syntax: Expand &$( and &$NN to use ${ } rather than $( )
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 29 Dec 2019 14:17:00 +0000 (14:17 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 30 Dec 2019 11:35:16 +0000 (11:35 +0000)
And now document the use of $&+ for recipes.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
README
generate

diff --git a/README b/README
index 0b84a0ec35dcfd6aec0c08736bd3f9b028b25b91..14cc5420f4783f5f4568c73e58eab1c48f5759f9 100644 (file)
--- 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.
 
 &$-            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.
 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
 
 &\$    =>      $
                         &-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
 
 A few contexts do not support $-doubling, such as directive arguments
 or places where this might imply $-quadrupling.  (There is no way to
index f571fa19d196efc9aa62299a487a095f0dba2724..f91cba8145134987c1191cea6660956ad67912b1 100755 (executable)
--- a/generate
+++ b/generate
@@ -361,10 +361,10 @@ sub process_input_mk ($$$$) {
            elsif (s{^\$\-}{}) { $ddbl=undef; }
            elsif (s{^\$\+}{}) { $ddbl=1; }
            elsif (s{^\$\(}{}) {
            elsif (s{^\$\-}{}) { $ddbl=undef; }
            elsif (s{^\$\+}{}) { $ddbl=1; }
            elsif (s{^\$\(}{}) {
-               ddbl_only($&); oud "\$(";
+               ddbl_only($&); oud "\${";
                $note_varref->($2,!!$1) if m{^($esc)?([^()\$]+\))};
            }
                $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 ';
            elsif (s{^\$\{}{}) {
                err 'macro invocation cannot be re-$-doubled' if $ddbl;
                od '${eval ${call ';