Buy commercial curl support from WolfSSL. We help you work
out your issues, debug your libcurl applications, use the API, port to new
platforms, add new features and more. With a team lead by the curl founder
himself.
Re: Exit status not reflecting 404 with --fail
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Hans Henrik Bergan via curl-users <curl-users_at_lists.haxx.se>
Date: Mon, 27 Nov 2023 15:13:39 +0100
rule of thumb, use `type curl` not `which curl`
(most often either works, but in some situations, `which curl` could
output /usr/bin/curl and `type curl` could output `curl is a shell
builtin` or whatever)
On Mon, 27 Nov 2023 at 11:04, Timothe Litt via curl-users
<curl-users_at_lists.haxx.se> wrote:
>
>
> On 26-Nov-23 23:42, Ray Satiro via curl-users wrote:
>
> On 11/26/2023 9:51 PM, Timothe Litt via curl-users wrote:
>
>
> This reproducer appears to show a bug that prevents scripts from using the exit code to detect a 4xx failure:
>
> # curl -w "%{stderr}x:%{exitcode} r:%{response_code}\n" --fail https://www.google.com/nosuchuri >/dev/null
> % Total % Received % Xferd Average Speed Time Time Time Current
> Dload Upload Total Spent Left Speed
> 0 1570 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
> curl: (22) The requested URL returned error: 404
> x:22 r:404
>
> # echo $?
> 0
>
> The error message is correct, but since --fail is specified I expected $? to be 22. Note from the -w that the exitcode is set to 22, but is not delivered to the shell.
>
> The response code is 404.
>
> Same behavior if the (diagnostic) -w is omitted... (and/or -s added)
>
>
> I can't reproduce this in Linux or in Windows. Can you show the verbose output? What options are in your curlrc?
>
> Sometimes curl isn't curl.
>
> I found the issue. The user had aliased curl to a wrapper script that didn't properly pass on the exit code.
>
> curl --version doesn't show this. Add to the checklist: 'which curl'. Sigh.
>
> Sorry for the false alarm. Thanks for looking at this.
>
> Timothe Litt
> ACM Distinguished Engineer
> --------------------------
> This communication may not represent the ACM or my employer's views,
> if any, on the matters discussed.
>
> --
> Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
> Etiquette: https://curl.se/mail/etiquette.html
Date: Mon, 27 Nov 2023 15:13:39 +0100
rule of thumb, use `type curl` not `which curl`
(most often either works, but in some situations, `which curl` could
output /usr/bin/curl and `type curl` could output `curl is a shell
builtin` or whatever)
On Mon, 27 Nov 2023 at 11:04, Timothe Litt via curl-users
<curl-users_at_lists.haxx.se> wrote:
>
>
> On 26-Nov-23 23:42, Ray Satiro via curl-users wrote:
>
> On 11/26/2023 9:51 PM, Timothe Litt via curl-users wrote:
>
>
> This reproducer appears to show a bug that prevents scripts from using the exit code to detect a 4xx failure:
>
> # curl -w "%{stderr}x:%{exitcode} r:%{response_code}\n" --fail https://www.google.com/nosuchuri >/dev/null
> % Total % Received % Xferd Average Speed Time Time Time Current
> Dload Upload Total Spent Left Speed
> 0 1570 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
> curl: (22) The requested URL returned error: 404
> x:22 r:404
>
> # echo $?
> 0
>
> The error message is correct, but since --fail is specified I expected $? to be 22. Note from the -w that the exitcode is set to 22, but is not delivered to the shell.
>
> The response code is 404.
>
> Same behavior if the (diagnostic) -w is omitted... (and/or -s added)
>
>
> I can't reproduce this in Linux or in Windows. Can you show the verbose output? What options are in your curlrc?
>
> Sometimes curl isn't curl.
>
> I found the issue. The user had aliased curl to a wrapper script that didn't properly pass on the exit code.
>
> curl --version doesn't show this. Add to the checklist: 'which curl'. Sigh.
>
> Sorry for the false alarm. Thanks for looking at this.
>
> Timothe Litt
> ACM Distinguished Engineer
> --------------------------
> This communication may not represent the ACM or my employer's views,
> if any, on the matters discussed.
>
> --
> Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
> Etiquette: https://curl.se/mail/etiquette.html
-- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users Etiquette: https://curl.se/mail/etiquette.htmlReceived on 2023-11-27