Re: Exit status not reflecting 404 with --fail

Ray Satiro via curl-users <[email protected]>
Newsgroups gmane.comp.web.curl.general
Message-ID <[email protected]>
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?

-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.