Let's assume we have a couple of files whose names need to be quoted when used in a shell:
echo A > 'a.$A'
echo B > 'b.$B'
And there is a Makefile with a rule that depends on these files:
all: a.$$A b.$$B
cat $+
The above would work for the files with simple names but for the ones in the example it produces:
cat a.$A b.$B
cat: a.: No such file or directory
cat: b.: No such file or directory
It looks like the shell expands the $A and $B expressions to empty strings.
If I quote the variable as cat '$+', then the expansion is prevented but all prerequisites are passed as a single argument:
cat 'a.$A b.$B'
cat: 'a.$A b.$B': No such file or directory
The fact that it's a single argument is sort of expected according to the documentation:
The names of all the prerequisites […], with spaces between them.
The question is, is there a way to obtain all the prerequisites as individual arguments to be able to quote them?