Should warn about unquoted spaces in variable values #153
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: ariadne/pkgconf#153
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
With a
.pc
file like this:The output looks like this:
It seems that the tokenization is broken. In addition, the paths outputted are not escaped or quoted at all. The correct output would be:
--cflags
and--cflags-only-I
are broken in the same way.Note that pkg-config is broken in the same way and more, so projects that use paths with spaces are currently totally broken. This change will only improve the current situation and make pkg-config actually usable on Windows where paths with spaces are common.
It would be great to fix this because pkgconf is probably the best option for getting pkg-config on Windows and I've been looking into including it with our meson MSI installers. 😄
This is basically a duplicate of #139.
The solution in my opinion is to properly quote paths with spaces, e.g.
prefix="/usr/with spaces"
.The quoting should be double-quote to allow POSIX shell compatibility with fragments such as
-I"/usr/with spaces"/include
, as I understand it, single-quote is not compatible in that way.That does work, but IMO pkgconf should output a warning when it finds unquoted space in variables. Every single pkg-config generator (via autoconf or whatever else) does not shell-quote the values of variables in .pc files, so they're all broken. It would also reduce the chances of someone else filing a duplicate bug. ;)
Single quotes work just fine for that, and they are superior because shell expansion cannot happen inside them—
$foo
, etc.$
is common in filenames on Windows, so I think it's worth preferring'
over"
.One more thing: some generators quote spaces with
\
which is totally broken on Windows, so perhaps pkgconf should also warn about that.Hmm, quoting with
'
or"
does notinteract well with the usage ofwork at all.${prefix}
in variable valuesEscaping with
\
does work, but as I said earlier, that does not work well on Windows because\
is a path separator.Yes it’s quite a mess unfortunately.
Spaces in paths have not gotten much consideration with pkg-config in general.
I am still thinking on how to best attack this.
So we are going to redesign the way we quote things in pkgconf 1.4 to follow POSIX instead of trying to do what the freedesktop implementation does (which I think we can all agree is not very sane).
I had previously wanted to go in this direction, but decided not to because I hadn't strongly familiarized myself with the POSIX standard in this regard, but after doing so, I believe that leveraging POSIX single-quotes as described in this bug is the right way forward.
This also makes it possible for us to do the right thing when running under cmd.exe (using double-quotes there) and other DCL derivatives (such as on OpenVMS).
Great news, thanks for working on this. pkgconf is quickly becoming the recommended pkgconfig implementation for me on Windows. :)
It would be ideal if this implementation was somewhat compatible with the fdo implementation (it's a superset after all). Specifically, quoting spaces with
\
inside .pc files would keep working, and would output arguments quoted with'
:Meson (and other projects) have to output pkgconfig files like that for compatibility with the fdo pkg-config implementation. Eventually we can get rid of this and use POSIX quoting inside the .pc file.
Meson already uses
shlex.split()
for splitting the output, and Autotools uses shell, so overall things would work just fine with POSIX quoting in the output.That's the lexing side which is what #139 is about.
Specifically an example of #139 deficiency:
Is there user-facing documentation somewhere that says how I should generate my
.pc
files?Something that describes (e.g. in the
man
page) how quoting should be done, such as making clear which ofshould be used?
No, that specific item hasn't been addressed, but patches are welcome.