-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Formatted String #10323
Comments
- Clarify that in Windows batch files the % must be escaped as %%, and at the command prompt it cannot be escaped which could lead to incorrect expansion. Prior to this change the doc implied % must be escaped as %% in win32 always. --- Examples: If curl --write-out "%{http_code}" is executed in a batch file: {http_code} If curl --write-out "%%{http_code}" is executed in a batch file: %{http_code} If curl --write-out "%{http_code}" is executed from the command prompt: %{http_code} If curl --write-out "%%{http_code}" is executed from the command prompt: %%{http_code} At the command prompt something like "%{speed_download}%{http_code}" would first be parsed by the command interpreter as %{speed_download}% and would be expanded as environment variable {speed_download} if it existed, though that's highly unlikely since Windows environment names don't use braces. --- Reported-by: Muhammad Hussein Ammari Fixes curl#10323 Closes #xxxx
- Clarify that in Windows batch files the % must be escaped as %%, and at the command prompt it cannot be escaped which could lead to incorrect expansion. Prior to this change the doc implied % must be escaped as %% in win32 always. --- Examples: If curl --write-out "%{http_code}" is executed in a batch file: {http_code} If curl --write-out "%%{http_code}" is executed in a batch file: %{http_code} If curl --write-out "%{http_code}" is executed from the command prompt: %{http_code} If curl --write-out "%%{http_code}" is executed from the command prompt: %%{http_code} At the command prompt something like "%{speed_download}%{http_code}" would first be parsed by the command interpreter as %{speed_download}% and would be expanded as environment variable {speed_download} if it existed, though that's highly unlikely since Windows environment names don't use braces. --- Reported-by: Muhammad Hussein Ammari Ref: curl/curl#10337 Fixes curl/curl#10323 Closes #xxxx
The manual says:
The book says:
I think we could make it clearer though. The escaping is needed for batch files but cannot be done if the command is typed at the prompt. I've submitted two PRs, one for the book and one for manpage. |
- Clarify that in Windows batch files the % must be escaped as %%, and at the command prompt it cannot be escaped which could lead to incorrect expansion. Prior to this change the doc implied % must be escaped as %% in win32 always. --- Examples showing how a write-out argument is received by curl: If curl --write-out "%{http_code}" is executed in a batch file: {http_code} If curl --write-out "%%{http_code}" is executed in a batch file: %{http_code} If curl --write-out "%{http_code}" is executed from the command prompt: %{http_code} If curl --write-out "%%{http_code}" is executed from the command prompt: %%{http_code} At the command prompt something like "%{speed_download}%{http_code}" would first be parsed by the command interpreter as %{speed_download}% and would be expanded as environment variable {speed_download} if it existed, though that's highly unlikely since Windows environment names don't use braces. --- Reported-by: Muhammad Hussein Ammari Ref: curl/everything-curl#279 Fixes #10323 Closes #10337
- Clarify that in Windows batch files the % must be escaped as %%, and at the command prompt it cannot be escaped which could lead to incorrect expansion. Prior to this change the doc implied % must be escaped as %% in win32 always. --- Examples showing how a write-out argument is received by curl: If curl --write-out "%{http_code}" is executed in a batch file: {http_code} If curl --write-out "%%{http_code}" is executed in a batch file: %{http_code} If curl --write-out "%{http_code}" is executed from the command prompt: %{http_code} If curl --write-out "%%{http_code}" is executed from the command prompt: %%{http_code} At the command prompt something like "%{speed_download}%{http_code}" would first be parsed by the command interpreter as %{speed_download}% and would be expanded as environment variable {speed_download} if it existed, though that's highly unlikely since Windows environment names don't use braces. --- Reported-by: Muhammad Hussein Ammari Ref: curl/everything-curl#279 Fixes curl#10323 Closes curl#10337
Description
In the
.cmd
/.bat
script files on Windows, the --write-out option does not work and we have to use two percent signs (%%) instead of one percent signs (%) in the formatted string.For example, the following command does not work:
But this command works:
Please mention this point in this article because my friend thought that the Windows build of cURL has a problem:
https://everything.curl.dev/usingcurl/verbose/writeout
Thanks.
What is the cause of this problem?
Actually, there is no problem. Command Prompt variables comprise a % character followed by a name, for example:
The text was updated successfully, but these errors were encountered: