From 291014f5a360a39bf99e4519e3ffb6c12d90d253 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 29 Dec 2019 14:03:28 +0000 Subject: [PATCH] Syntax: expand &$... to ${....} rather than $(....) This makes it possible to use in $-doubled shell runes as well as in make syntax. Signed-off-by: Ian Jackson --- README | 4 ++-- generate | 2 +- tests/filter/Dir.mk.expected | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README b/README index e303788..2b8061b 100644 --- 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 -&$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... & @@ -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 - 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 $&... diff --git a/generate b/generate index 5106129..ffd3e5d 100755 --- 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); - od "\$(${var_prefix}$1)"; + od "\${${var_prefix}$1}"; } elsif (s{^([~^]?)(?=$lc_re)}{}) { od $pfxmap{$1} } elsif (s{^_}{}) { od $var_prefix } diff --git a/tests/filter/Dir.mk.expected b/tests/filter/Dir.mk.expected index 5205a3a..53da9e3 100644 --- a/tests/filter/Dir.mk.expected +++ b/tests/filter/Dir.mk.expected @@ -10,10 +10,10 @@ TOP_WARN += 3 # $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) } }} -- 2.30.2