-
Notifications
You must be signed in to change notification settings - Fork 99
Do not escape double quotes for command line arguments on Windows #113
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Commit ffd4c73 introduced the `util::is_ready()` function, which has never been used internally and is not part of the public API. This change removes the function.
The `util::quote_argument()` function is specific to Windows and is used in code already guarded by `#ifdef __USING_WINDOWS__`.
This change fixes the handling of double quotes and aligns the behavior with Python's `Popen` class. For example: ``` >py -3 >>> import subprocess >>> p = subprocess.Popen("cmd.exe /c dir \"C:\\Program Files\"", stdout=subprocess.PIPE, text=True) >>> print(f"Captured stdout:\n{stdout}") ``` Currently, the same command line processed by the `quote_argument()` function looks like `cmd.exe /c dir "\"C:\Program" "Files\""`, which is broken. With this change, it looks correct: `cmd.exe /c dir "C:\Program Files"`.
The new test ensures that no regressions are introduced in the future.
arun11299
approved these changes
Apr 24, 2025
hebasto
added a commit
to hebasto/bitcoin
that referenced
this pull request
Apr 27, 2025
… Windows * refactor: Guard `util::quote_argument()` with `#ifdef __USING_WINDOWS__` The `util::quote_argument()` function is specific to Windows and is used in code already guarded by `#ifdef __USING_WINDOWS__`. * Do not escape double quotes for command line arguments on Windows This change fixes the handling of double quotes and aligns the behavior with Python's `Popen` class. For example: ``` >py -3 >>> import subprocess >>> p = subprocess.Popen("cmd.exe /c dir \"C:\\Program Files\"", stdout=subprocess.PIPE, text=True) >>> print(f"Captured stdout:\n{stdout}") ``` Currently, the same command line processed by the `quote_argument()` function looks like `cmd.exe /c dir "\"C:\Program" "Files\""`, which is broken. With this change, it looks correct: `cmd.exe /c dir "C:\Program Files"`. Github-Pull: arun11299/cpp-subprocess#113 Rebased-From: ed313971c04ac10dc006104aba07d016ffc6542a
hebasto
added a commit
to hebasto/bitcoin
that referenced
this pull request
Apr 27, 2025
… Windows * refactor: Guard `util::quote_argument()` with `#ifdef __USING_WINDOWS__` The `util::quote_argument()` function is specific to Windows and is used in code already guarded by `#ifdef __USING_WINDOWS__`. * Do not escape double quotes for command line arguments on Windows This change fixes the handling of double quotes and aligns the behavior with Python's `Popen` class. For example: ``` >py -3 >>> import subprocess >>> p = subprocess.Popen("cmd.exe /c dir \"C:\\Program Files\"", stdout=subprocess.PIPE, text=True) >>> print(f"Captured stdout:\n{stdout}") ``` Currently, the same command line processed by the `quote_argument()` function looks like `cmd.exe /c dir "\"C:\Program" "Files\""`, which is broken. With this change, it looks correct: `cmd.exe /c dir "C:\Program Files"`. Github-Pull: arun11299/cpp-subprocess#113 Rebased-From: ed313971c04ac10dc006104aba07d016ffc6542a
hebasto
added a commit
to hebasto/bitcoin
that referenced
this pull request
May 1, 2025
… Windows * refactor: Guard `util::quote_argument()` with `#ifdef __USING_WINDOWS__` The `util::quote_argument()` function is specific to Windows and is used in code already guarded by `#ifdef __USING_WINDOWS__`. * Do not escape double quotes for command line arguments on Windows This change fixes the handling of double quotes and aligns the behavior with Python's `Popen` class. For example: ``` >py -3 >>> import subprocess >>> p = subprocess.Popen("cmd.exe /c dir \"C:\\Program Files\"", stdout=subprocess.PIPE, text=True) >>> print(f"Captured stdout:\n{stdout}") ``` Currently, the same command line processed by the `quote_argument()` function looks like `cmd.exe /c dir "\"C:\Program" "Files\""`, which is broken. With this change, it looks correct: `cmd.exe /c dir "C:\Program Files"`. Github-Pull: arun11299/cpp-subprocess#113 Rebased-From: ed313971c04ac10dc006104aba07d016ffc6542a
hebasto
added a commit
to bitcoin/bitcoin
that referenced
this pull request
May 5, 2025
cd95c9d subprocess: check and handle fcntl(F_GETFD) failure (Tomás Andróil) b7288de subprocess: Proper implementation of wait() on Windows (Haowen Liu) 7423214 subprocess: Do not escape double quotes for command line arguments on Windows (Hennadii Stepanov) bb9ffea subprocess: Explicitly define move constructor of Streams class (Shunsuke Shimizu) 174bd43 subprocess: Avoid leaking POSIX name aliases beyond `subprocess.h` (Hennadii Stepanov) 7997b76 subprocess: Fix cross-compiling with mingw toolchain (Hennadii Stepanov) 6476304 subprocess: Get Windows return code in wait() (Haowen Liu) d3f511b subprocess: Fix string_arg when used with rref (Haowen Liu) 2fd3f2f subprocess: Fix memory leaks (Haoran Peng) Pull request description: Most of these changes were developed during work on #29868 and #32342 and have since been upstreamed. As they are now merged, this PR backports them to our `src/util/subprocess.h` header. Required for #29868. A list of the backported PRs: - arun11299/cpp-subprocess#106 - arun11299/cpp-subprocess#110 - arun11299/cpp-subprocess#109 - arun11299/cpp-subprocess#99 - arun11299/cpp-subprocess#112 - arun11299/cpp-subprocess#107 - arun11299/cpp-subprocess#113 - arun11299/cpp-subprocess#116 - arun11299/cpp-subprocess#117 The following PRs were skipped for backporting: - arun11299/cpp-subprocess#108 because we are not planning to support this feature. - arun11299/cpp-subprocess#101 because that change has been already landed in #29849. ACKs for top commit: theStack: Light ACK cd95c9d laanwj: Code review re-ACK cd95c9d Tree-SHA512: f9b60b932957d2e1cad1d87f2ad8bb68c97136e9735eb78547018a42cc50c4652750367f29462eadb0512c27db1dd8a7d4b17a2f0aeab62b3dbf86db5f51a61c
w0xlt
pushed a commit
to w0xlt/bitcoin
that referenced
this pull request
May 7, 2025
… Windows * refactor: Guard `util::quote_argument()` with `#ifdef __USING_WINDOWS__` The `util::quote_argument()` function is specific to Windows and is used in code already guarded by `#ifdef __USING_WINDOWS__`. * Do not escape double quotes for command line arguments on Windows This change fixes the handling of double quotes and aligns the behavior with Python's `Popen` class. For example: ``` >py -3 >>> import subprocess >>> p = subprocess.Popen("cmd.exe /c dir \"C:\\Program Files\"", stdout=subprocess.PIPE, text=True) >>> print(f"Captured stdout:\n{stdout}") ``` Currently, the same command line processed by the `quote_argument()` function looks like `cmd.exe /c dir "\"C:\Program" "Files\""`, which is broken. With this change, it looks correct: `cmd.exe /c dir "C:\Program Files"`. Github-Pull: arun11299/cpp-subprocess#113 Rebased-From: ed313971c04ac10dc006104aba07d016ffc6542a
alexanderwiederin
pushed a commit
to alexanderwiederin/bitcoin
that referenced
this pull request
May 8, 2025
… Windows * refactor: Guard `util::quote_argument()` with `#ifdef __USING_WINDOWS__` The `util::quote_argument()` function is specific to Windows and is used in code already guarded by `#ifdef __USING_WINDOWS__`. * Do not escape double quotes for command line arguments on Windows This change fixes the handling of double quotes and aligns the behavior with Python's `Popen` class. For example: ``` >py -3 >>> import subprocess >>> p = subprocess.Popen("cmd.exe /c dir \"C:\\Program Files\"", stdout=subprocess.PIPE, text=True) >>> print(f"Captured stdout:\n{stdout}") ``` Currently, the same command line processed by the `quote_argument()` function looks like `cmd.exe /c dir "\"C:\Program" "Files\""`, which is broken. With this change, it looks correct: `cmd.exe /c dir "C:\Program Files"`. Github-Pull: arun11299/cpp-subprocess#113 Rebased-From: ed313971c04ac10dc006104aba07d016ffc6542a
Eunovo
pushed a commit
to Eunovo/bitcoin
that referenced
this pull request
May 12, 2025
… Windows * refactor: Guard `util::quote_argument()` with `#ifdef __USING_WINDOWS__` The `util::quote_argument()` function is specific to Windows and is used in code already guarded by `#ifdef __USING_WINDOWS__`. * Do not escape double quotes for command line arguments on Windows This change fixes the handling of double quotes and aligns the behavior with Python's `Popen` class. For example: ``` >py -3 >>> import subprocess >>> p = subprocess.Popen("cmd.exe /c dir \"C:\\Program Files\"", stdout=subprocess.PIPE, text=True) >>> print(f"Captured stdout:\n{stdout}") ``` Currently, the same command line processed by the `quote_argument()` function looks like `cmd.exe /c dir "\"C:\Program" "Files\""`, which is broken. With this change, it looks correct: `cmd.exe /c dir "C:\Program Files"`. Github-Pull: arun11299/cpp-subprocess#113 Rebased-From: ed313971c04ac10dc006104aba07d016ffc6542a
luke-jr
pushed a commit
to luke-jr/bitcoin
that referenced
this pull request
Jun 6, 2025
… Windows * refactor: Guard `util::quote_argument()` with `#ifdef __USING_WINDOWS__` The `util::quote_argument()` function is specific to Windows and is used in code already guarded by `#ifdef __USING_WINDOWS__`. * Do not escape double quotes for command line arguments on Windows This change fixes the handling of double quotes and aligns the behavior with Python's `Popen` class. For example: ``` >py -3 >>> import subprocess >>> p = subprocess.Popen("cmd.exe /c dir \"C:\\Program Files\"", stdout=subprocess.PIPE, text=True) >>> print(f"Captured stdout:\n{stdout}") ``` Currently, the same command line processed by the `quote_argument()` function looks like `cmd.exe /c dir "\"C:\Program" "Files\""`, which is broken. With this change, it looks correct: `cmd.exe /c dir "C:\Program Files"`. Github-Pull: arun11299/cpp-subprocess#113 Rebased-From: ed313971c04ac10dc006104aba07d016ffc6542a Github-Pull: bitcoin#32358 Rebased-From: 7423214
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes the handling of double quotes and aligns the behavior with Python's
Popen
class. For example:Currently, the same command line processed by the
util::quote_argument()
function looks like:which is broken.
With PR change, it looks correct:
Additionally, this PR: