curl respects the locale's number format setting for parsing fractional seconds, it does not enforce dot · Issue #9969 · curl/curl · GitHub
Skip to content You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert curl respects the locale's number format setting for parsing fractional seconds, it does not enforce dot #9969 New issue Copy link New issue Copy link Closed Closed curl respects the locale's number format setting for parsing fractional seconds, it does not enforce dot #9969 Copy link Labels cmdline tool Description danielfaust opened on Nov 23, 2022 Issue body actions I did this In bash and zsh : curl --connect-timeout 3.14 https://example.com I expected the following The following printed out to stdout: <!doctype html> <html> <head> <title>Example Domain</title> ... </html> The actual result was curl: option --connect-timeout: expected a proper numerical parameter curl/libcurl version curl 7.81.0 (x86_64-pc-linux-gnu) libcurl/7.81.0 OpenSSL/3.0.2 zlib/1.2.11 brotli/1.0.9 zstd/1.4.8 libidn2/2.3.2 libpsl/0.21.0 (+libidn2/2.3.2) libssh/0.9.6/openssl/zlib nghttp2/1.43.0 librtmp/2.3 OpenLDAP/2.5.13 Release-Date: 2022-01-05 as well as curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3 Release-Date: 2020-01-08 operating system Ubuntu 22.04 LTS Linux hostname 5.15.0-53-generic #59 -Ubuntu SMP Mon Oct 17 18:53:30 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux With LC_NUMERIC="de_DE.UTF-8" as well as Ubuntu 20.04 LTS Linux hostname 5.15.0-52-generic #58 ~20.04.1-Ubuntu SMP Thu Oct 13 13:09:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux With LC_NUMERIC="de_DE.UTF-8" workaround Add export LC_NUMERIC="en_US.UTF-8" to environments requiring fractional seconds in the timeouts.
Activity bagder added cmdline tool on Nov 23, 2022 bagder commented on Nov 23, 2022 bagder on Nov 23, 2022 Member More actions Doesn't your command line and claim contradict each other? German uses comma and not a period ? (like Swedish btw) curl uses the dot-version (it ignores the locale) fixed and on purpose so that command lines become transferable between systems. This is intentional. The documentation could probably make that clearer.
Reacted by Marcel Raad and Daniel Faust danielfaust commented on Nov 23, 2022 danielfaust on Nov 23, 2022 Author More actions I recognize my mistake and I was about to close this issue, but then I re-read your answer and there's also something wrong: curl uses the dot-version (as it ignoring the locale) fixed and on purpose so that command lines become transferable between systems. This is intentional. Consider the following command line "dialogue": ~ export LC_NUMERIC="de_DE.UTF-8" ~ locale -k decimal_point decimal_point="," ~ curl --connect-timeout 3.14 https://example.com curl: option --connect-timeout: expected a proper numerical parameter curl: try 'curl --help' or 'curl --manual' for more information ~ curl --connect-timeout 3,14 https://example.com <!doctype html> <html> ... </html> ~ export LC_NUMERIC="en_US.UTF-8" ~ curl --connect-timeout 3,14 https://example.com curl: option --connect-timeout: expected a proper numerical parameter curl: try 'curl --help' or 'curl --manual' for more information Exactly like you I had the feeling that using a dot would be the proper way to do it, but it actually is the contrary of what the title of this issue says: So instead of Curl does not respect the locale's number format setting for parsing fractional seconds. it should be Curl applies the locale's number format setting when parsing fractional seconds.
This entire thing is pretty confusing to me, since I also would expect to use a dot on the command line for decimals in the parameters, but also respecting the locale isn't technically that wrong neiter. I'm managing 10+ servers which all have use LC_NUMERIC="en_US.UTF-8" and two Linux desktops which have LC_NUMERIC="de_DE.UTF-8" and there I was seeing this issue when using a script which I created on a server. Update: Sorry for being late with this reply to your answer.
You submitted the PR on the docs while I was typing this answer, so I didn't see it. Apparently this now makes the docs be officially in contradiction with what curl is actually doing. bagder commented on Nov 23, 2022 bagder on Nov 23, 2022 Member More actions Apparently this now makes the docs be officially in contradiction with what curl is actually doing. The fact that you said the complete opposite in the title is highly confusing...
Reacted by Daniel Faust bagder changed the title [-] Curl does not respect the locale's number format setting for parsing fractional seconds. [/-] [+] curl respects the locale's number format setting for parsing fractional seconds, it does not enforce dot [/+] on Nov 23, 2022 bagder commented on Nov 23, 2022 bagder on Nov 23, 2022 Member More actions Using 7.86.0 or 7.87.0-DEV on my Linux: LC_NUMERIC="de_DE.UTF-8" ./src/curl -m 3,14 localhost curl: option -m: expected a proper numerical parameter curl: try 'curl --help' or 'curl --manual' for more information bagder commented on Nov 23, 2022 bagder on Nov 23, 2022 Member More actions How do you build/get your curl? bagder commented on Nov 23, 2022 bagder on Nov 23, 2022 Member More actions Plain ubuntu install? danielfaust commented on Nov 23, 2022 danielfaust on Nov 23, 2022 Author More actions It's on Kubuntu 20.04 LTS and Kubuntu 22.04 LTS.
It's the version from the repository, I don't know it it was pre-installed or if I manually used apt install . Opening this issue was a result of this Stack Exchange post I made: https://unix.stackexchange.com/questions/725973/curl-option-connect-timeout-expected-a-proper-numerical-parameter The versions are curl 7.81.0 (x86_64-pc-linux-gnu) libcurl/7.81.0 OpenSSL/3.0.2 zlib/1.2.11 brotli/1.0.9 zstd/1.4.8 libidn2/2.3.2 libpsl/0.21.0 (+libidn2/2.3.2) libssh/0.9.6/openssl/zlib nghttp2/1.43.0 librtmp/2.3 OpenLDAP/2.5.13 Release-Date: 2022-01-05 and curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3 Release-Date: 2020-01-08 bagder commented on Nov 23, 2022 bagder on Nov 23, 2022 Member More actions I can also reproduce on ubuntu 20.04, both with the shipped version and my own build.
Clearly the setlocale() call has no effect... ? Reacted by Daniel Faust bagder commented on Nov 23, 2022 bagder on Nov 23, 2022 Member More actions If locale is an empty string, "", each part of the locale that should be modified is set according to the environment variables It turns out we should set it to "C" if we want to override it... danielfaust commented on Nov 23, 2022 danielfaust on Nov 23, 2022 Author More actions Thank you for your work. bagder added 2 commits that reference this issue on Nov 24, 2022 docs/cmdline-opts: curl uses dot as decimal separator 3f3f2eb tool_operate: override the locale and set "C" by force 4a06c35 bagder closed this as completed in 975efec on Nov 25, 2022 Sign up for free to join this conversation on GitHub.
Already have an account? Sign in to comment Metadata Metadata Assignees No one assigned Labels cmdline tool Type No type Projects No projects Milestone No milestone Relationships None yet Development No branches or pull requests Issue actions You can’t perform that action at this time.