chiark / gitweb /
Syntax: expand &$... to ${....} rather than $(....)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 29 Dec 2019 14:03:28 +0000 (14:03 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 30 Dec 2019 11:35:16 +0000 (11:35 +0000)
This makes it possible to use in $-doubled shell runes as well as in
make syntax.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
README
generate
tests/filter/Dir.mk.expected

diff --git a/README b/README
index e303788b362856eb0474c4b2618c49b35ee32288..2b8061b228bd95be5163dbe94cf5ddb1880c44be 100644 (file)
--- a/README
+++ b/README
@@ -114,7 +114,7 @@ So pathname syntax is a subset of:
 &\$            =>      $               provided for $-doubling regimes
 &\NEWLINE                              eats the newline and vanishes
 
 &\$            =>      $               provided for $-doubling regimes
 &\NEWLINE                              eats the newline and vanishes
 
-&$VARIABLE     =>      $(sub_dir_VARIABLE)     or $(TOP_VARIABLE)
+&$VARIABLE     =>      ${sub_dir_VARIABLE}     or ${TOP_VARIABLE}
        VARIABLE is ASCII starting with a letter and matching \w+
 
 & thing thing... &
        VARIABLE is ASCII starting with a letter and matching \w+
 
 & thing thing... &
@@ -334,7 +334,7 @@ suppressed with the &:warn directive.  The warning tags are:
        interpret this as $(F)BAR.  It's normally better to write
        it this way, at least if the variable expansion is followed
        by more letters.  Note that &$FOO works differently to
        interpret this as $(F)BAR.  It's normally better to write
        it this way, at least if the variable expansion is followed
        by more letters.  Note that &$FOO works differently to
-       raw make: it expands to $(sub_dir_FOO).
+       raw make: it expands to ${sub_dir_FOO}.
 
     broken-var-ref
         An attempt at variable expansion looking like $&...
 
     broken-var-ref
         An attempt at variable expansion looking like $&...
index 510612993f34fe82f8c6f60689d73552d5d7eeb6..ffd3e5dfdb1e18951ac9771efef71c93e3e64143 100755 (executable)
--- a/generate
+++ b/generate
@@ -350,7 +350,7 @@ sub process_input_mk ($$$$) {
            elsif (m{^(?=$caps_re)}) { od $var_prefix }
            elsif (s{^\$([A-Za-z]\w+)}{}) {
                $note_varref->($1,1);
            elsif (m{^(?=$caps_re)}) { od $var_prefix }
            elsif (s{^\$([A-Za-z]\w+)}{}) {
                $note_varref->($1,1);
-               od "\$(${var_prefix}$1)";
+               od "\${${var_prefix}$1}";
            }
            elsif (s{^([~^]?)(?=$lc_re)}{}) { od $pfxmap{$1} }
            elsif (s{^_}{}) { od $var_prefix }
            }
            elsif (s{^([~^]?)(?=$lc_re)}{}) { od $pfxmap{$1} }
            elsif (s{^_}{}) { od $var_prefix }
index 5205a3a85577554837adaeaf147a423951c1e958..53da9e3ee1bfbb9fe2134c7ae49c2246b64db7be 100644 (file)
@@ -10,10 +10,10 @@ TOP_WARN += 3
 # $WARN
 # $(WARN)
 # $(TOP_WARN)
 # $WARN
 # $(WARN)
 # $(TOP_WARN)
-# $(TOP_WARN)
+# ${TOP_WARN}
 
 
-# $(TOP_NOWARN1) $(NOWARN1)
-# $(TOP_NOWARN2) $(NOWARN2)
+# ${TOP_NOWARN1} $(NOWARN1)
+# ${TOP_NOWARN2} $(NOWARN2)
 
 ${eval ${call  some-macro, 42, $$x, {  $(foreach something) } }}
 
 
 ${eval ${call  some-macro, 42, $$x, {  $(foreach something) } }}