NetBSD/usr.bin/make/unit-tests/dollar.exp
rillig 58281fc596 usr.bin/make: fix test for dollar and backslash at eol
The previous version of this test relied on the way how the shell
interprets a lonely backslash at the end of the line.  The NetBSD and
FreeBSD shells print the backslash, while Bash doesn't.

While here, make the escaping a bit simpler and align the test
descriptions with the actual test data.
2020-05-17 09:37:48 +00:00

52 lines
1.5 KiB
Plaintext

Printing dollar from literals and variables
To survive the parser, a dollar character must be doubled.
1 dollar literal => <single-quote-var-value>
1 dollar literal eol => <>
2 dollar literal => <$>
4 dollar literal => <$$>
Some hungry part of make eats all the dollars after a :U modifier.
1 dollar default => <>
2 dollar default => <>
4 dollar default => <>
This works as expected.
1 dollar variable => <>
2 dollar variable => <$>
4 dollar variable => <$$>
Some hungry part of make eats all the dollars after a :U modifier.
1 dollar var-default => <>
2 dollar var-default => <$>
4 dollar var-default => <$$>
Dollar in :S pattern
S,$,word, => <$XYword>
S,$X,word, => <$XY>
S,$$X,word, => <$XY>
S,$$$X,word, => <$XY>
S,$X,replaced, => <replaced>
S,$$X,replaced, => <replaced>
S,$$$X,replaced, => <replaced>
Dollar in :C character class
The A is replaced because the $$ is reduced to a single $,
which is then resolved to the variable X with the value VAR_X.
The effective character class becomes [VAR_XY].
C,[$$XY],<&>,g => <$<A><X><Y>>
Dollar in :C pattern
For some reason, multiple dollars are folded into one.
C,$,dollar,g => <>
C,$$,dollar,g => <>
Dollar in :S replacement
For some reason, multiple dollars are folded into one.
S,word,a$Xo, => <aVAR_Xo>
S,word,a$$Xo, => <aVAR_Xo>
S,word,a$$$Xo, => <aVAR_Xo>
exit status 0