Re: Quoting special characters (was: Re: Possible solution for special characters in makefile paths)
Frank Heckenbach <[email protected]>
| Newsgroups | gmane.comp.gnu.make.devel |
|---|---|
| Message-ID | <[email protected]> |
Eli Zaretskii wrote: > OK, but the issue of how to expand $[foo bar] in various contexts > still needs to be discussed, because (unlike with the backslash) we > cannot leave it in the expansion. I think with our current proposal, there's no need for $[] at all, so the issue is moot. "$[foo bar]" will just mean the value of a variable called "[foo" and then "bar]", just like now. (Unless we add, unrelated to the rest, $[] as a quoting function, cf. below, but I don't think it will be needed so often as to warrant special syntax; $(quote) should do.) > > - Values from the command-line or environment variables (I think the > > two are equivalent): Now that's a little problem. One might like > > to quote them like the previous items, so something like > > make FOO="my file name" > > would work as intended. But that would break compatibility when a > > variable is actually meant to contain a list of filenames, or see > > my LOG_START example for another case that must not be turned into > > a single word. So I'd say since make has no way of knowing what a > > variable is meant to be, it must assume separate words and store > > it as is (also for backward-compatibility). If something else is > > intended, the user will need to do additional quoting: > > make FOO="'my file name'" BAR="file1 file2 file3" > > I think we will need to provide a quoting function, something like a > wrapper for the gnulib's quotearg module, I agree. Though as discussed elsewhere, I'd prefer for make to support full shell-style quoting, thus $(quote) could just add '' and escape embedded ' characters. And of course, $(quote) (either version) would be POSIX sh specific. Users of other shells could write their own quote functions (or make might provide some common alternatives under other names). At least, there are no conflicts, since $(quote) would never be applied automatically, and the makefile author will know which one to use when they need one. Paul Eggert wrote: > This reminds me of the quadrigraphs of Autoconf, which are used for a > similar purpose. Unlike your proposal, they are visible to the user; > this tends to make things easier to follow when debugging. Perhaps > 'make' could steal from their syntax. Thanks for the pointer. However, I must say those quadrigraphs are not very readable. To replace rare special charactes, as in autoconf, that's alright, but here we're talking about relatively common things like spaces in file names. I don't think forcing users to user quadrigraphs there would be well received.