Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backends: restore shlex quoting of MESONINTROSPECT #12807

Merged
merged 1 commit into from
Feb 11, 2024
Merged

backends: restore shlex quoting of MESONINTROSPECT #12807

merged 1 commit into from
Feb 11, 2024

Conversation

joukewitteveen
Copy link
Contributor

The type of quoting was changed in 522392e to one that is suitable for use with cmd.exe on Windows. However, the documentation states that the type of quoting in MESONINTROSPECT is compatible with shlex.split() and elsewhere in the code, the same variable is still quoted with shlex.quote(). As mostly identified in #12148, there are a few choices:

  1. Use shlex.quote() consistently and support Python but not cmd.exe.
  2. Use join_args and support cmd.exe but not Python.
  3. Use join_args and support splitting through the mesonbuild Python library.

This commit implements the first option and reverts part of 522392e.

Regression testing is implemented in #12115.

Fixes #12148

@joukewitteveen
Copy link
Contributor Author

The ' '.join(shlex.quote(x) for x in ...) code occurs quite often. Maybe we should make a mesonlib function for it as well? It would be a sibling of join_args and maybe prevent people like me from being tempted to 'clean up' and just use join_args in the future.

@eli-schwartz
Copy link
Member

It's really just a reimplementation of python 3.8's shlex.join(). I think a suitable internal name would be mesonlib.join_unix_args, which we might or might not want to differentiate from join_native_args (by renaming join_args). Depends on whether we figure that potential contributors will understand by default that join_args is native by default and join_unix_args is for when you specifically want unix style, which does seem like a reasonable assumption.

@joukewitteveen joukewitteveen mentioned this pull request Feb 4, 2024
@joukewitteveen
Copy link
Contributor Author

join_unix_args is for when you specifically want unix style

We can maybe do a bit better here, because crucially this style will be easy to use from Python as well (not just from a Unix shell). That makes it sensible for use on Windows too (e.g. this whole MESONINTROSPECT business). At any rate, this can be done after merging the current pull request, which fixes a real bug.

mesonbuild/backend/backends.py Outdated Show resolved Hide resolved
The type of quoting was changed in 522392e to one that is suitable for
use with cmd.exe on Windows. However, the documentation states that the
type of quoting in MESONINTROSPECT is compatible with shlex.split() and
elsewhere in the code, the same variable is still quoted with
shlex.quote(). As mostly identified in #12148, there are a few choices:
1. Use shlex.quote() consistently and support Python but not cmd.exe.
2. Use join_args and support cmd.exe but not Python.
3. Use join_args and support splitting through the mesonbuild Python library.

This commit implements the first option and reverts part of 522392e.

Regression testing is implemented in #12115.

Fixes #12148
@eli-schwartz eli-schwartz merged commit 10e2692 into mesonbuild:master Feb 11, 2024
35 checks passed
@nirbheek nirbheek added this to the 1.3.3 milestone Feb 11, 2024
@nirbheek nirbheek modified the milestones: 1.3.3, 1.3.2, 1.4.0 Feb 11, 2024
akihikodaki added a commit to akihikodaki/qemu that referenced this pull request Mar 26, 2024
We need meson v1.4.0 to fix MESONINTROSPECT quoting on Windows:
mesonbuild/meson#12807

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
akihikodaki added a commit to akihikodaki/qemu that referenced this pull request Mar 26, 2024
We need meson v1.4.0 to fix MESONINTROSPECT quoting on Windows:
mesonbuild/meson#12807

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
akihikodaki added a commit to akihikodaki/qemu that referenced this pull request Mar 27, 2024
We need meson v1.4.0 to fix MESONINTROSPECT quoting on Windows:
mesonbuild/meson#12807

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
patchew-importer pushed a commit to patchew-project/qemu that referenced this pull request Mar 27, 2024
We need meson v1.4.0 to fix MESONINTROSPECT quoting on Windows:
mesonbuild/meson#12807

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20240327-meson-v3-1-7e6cdef1be8a@daynix.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Arguments in MESONINTROSPECT are escaped incosistently
3 participants