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

Windows: Quote more batch file arguments #108218

Merged
merged 1 commit into from
Feb 23, 2023
Merged

Conversation

ChrisDenton
Copy link
Member

@ChrisDenton ChrisDenton commented Feb 18, 2023

Make sure to always quote batch file arguments that contain command prompt special characters.

Additionally add /d command line parameter to disable any autorun scripts that may change the way variable expansion works. This makes it more consistent across systems and may help avoid surprises.

Background Info

CreateProcess with the lpApplicationName set can only be used to run .exe files and not script files such as .bat. However, for historical reasons, we do have special handling so that .bat files will be correctly run with cmd.exe as the application.

In Windows, command line arguments are passed as a single string (not an array). Applications can parse this string however they like but most follow the standard MSVC C/C++ convention. But cmd.exe uses different argument parsing rules to other Windows programs (because it emulates old DOS). This PR aims to help smooth over some of the differences.

r? libs

@ChrisDenton ChrisDenton added O-windows Operating system: Windows T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 18, 2023
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 18, 2023
@rustbot
Copy link
Collaborator

rustbot commented Feb 18, 2023

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

Make sure to quote batch file arguments that contain command prompt special characters.

Additionally add `/d` command line parameter to disable any commands that may change the way variable expansion works.
@cuviper
Copy link
Member

cuviper commented Feb 22, 2023

@bors r+

@bors
Copy link
Contributor

bors commented Feb 22, 2023

📌 Commit 0b7c867 has been approved by cuviper

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 22, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 23, 2023
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#108063 (Ban associated type bounds in bad positions)
 - rust-lang#108208 (Correctly handle aggregates in DataflowConstProp)
 - rust-lang#108218 (Windows: Quote more batch file arguments)
 - rust-lang#108349 (rustdoc: Prevent duplicated imports)
 - rust-lang#108350 (Use associated type bounds in some places in the compiler)
 - rust-lang#108358 (Add git config command to `.git-blame-ignore-revs`)
 - rust-lang#108373 (hir-analysis: make where-clause-on-main diagnostic translatable)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c4a4bce into rust-lang:master Feb 23, 2023
@rustbot rustbot added this to the 1.69.0 milestone Feb 23, 2023
@ChrisDenton ChrisDenton deleted the cmd-escape branch January 22, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Operating system: Windows S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants