tool_msgs: make notef() respect --silent

Until 8.17.0 the --silent check lived in voutf(), so it covered every
message type that went through it. 56450ce26f moved that check out to
the callers so that errorf() could honour --show-error, and warnf() and
errorf() got the check back, but notef() did not. Since then "Note:"
messages have been printed even with --silent, as long as tracing was
on.

Reported-by: Jace Laquerre
Fixes #22623
Closes #22625
This commit is contained in:
Alb3e3 2026-08-19 21:53:44 +04:00 committed by Daniel Stenberg
parent aab0518d04
commit 74b732f637
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 121 additions and 5 deletions

View file

@ -17,8 +17,8 @@ Example:
# `--silent`
Silent or quiet mode. Do not show progress meter, warning messages or error
messages. Makes curl mute. It still outputs the data you ask for, potentially
Silent or quiet mode. Do not show progress meter, note messages, warning
messages or error messages. Makes curl mute. It still outputs the data you ask for, potentially
even to the terminal/stdout unless you redirect it.
Use --show-error in addition to this option to disable progress meter but

View file

@ -74,11 +74,11 @@ static void voutf(const char *prefix, const char *fmt, va_list ap)
/*
* Emit 'note' formatted message on configured 'errors' stream, if verbose was
* selected.
* selected and mute (--silent) was not.
*/
void notef(const char *fmt, ...)
{
if(global && global->tracetype) {
if(global && global->tracetype && !global->silent) {
va_list ap;
va_start(ap, fmt);
voutf(NOTE_PREFIX, fmt, ap);

View file

@ -225,7 +225,7 @@ test1685 test1686 \
\
test1700 test1702 test1703 test1704 test1705 test1706 test1707 \
test1708 test1709 test1710 test1711 test1712 test1713 test1714 test1715 \
test1720 test1721 test1722 test1723 test1724 test1725 \
test1720 test1721 test1722 test1723 test1724 test1725 test1740 test1741 \
\
test1800 test1801 test1802 test1847 test1848 test1849 test1850 test1851 \
\

58
tests/data/test1740 Normal file
View file

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
HTTP
HTTP POST
--silent
</keywords>
</info>
# Server-side
<reply>
<data crlf="headers" nocheck="yes">
HTTP/1.1 200 OK
Date: Tue, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake
Content-Length: 6
Connection: close
Content-Type: text/html
-foo-
</data>
</reply>
# Client-side
<client>
<server>
http
</server>
<setenv>
# set the terminal wide to avoid word wrap in the message
COLUMNS=10000
</setenv>
<name>
--silent suppresses Note: messages when verbose
</name>
<command option="no-output">
http://%HOSTIP:%HTTPPORT/%TESTNUMBER --silent -X POST -d foo -o %LOGDIR/out%TESTNUMBER -w '%{stderr}done\n'
</command>
</client>
# Verify data after the test has been "shot"
<verify>
<protocol crlf="yes" nonewline="yes">
POST /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 3
Content-Type: application/x-www-form-urlencoded
foo
</protocol>
<stderr mode="text">
done
</stderr>
</verify>
</testcase>

58
tests/data/test1741 Normal file
View file

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
HTTP
HTTP POST
</keywords>
</info>
# Server-side
<reply>
<data crlf="headers" nocheck="yes">
HTTP/1.1 200 OK
Date: Tue, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake
Content-Length: 6
Connection: close
Content-Type: text/html
-foo-
</data>
</reply>
# Client-side
<client>
<server>
http
</server>
<setenv>
# set the terminal wide to avoid word wrap in the message
COLUMNS=10000
</setenv>
<name>
Note: messages are shown when verbose without --silent
</name>
<command option="no-output">
http://%HOSTIP:%HTTPPORT/%TESTNUMBER -X POST -d foo -o %LOGDIR/out%TESTNUMBER --no-progress-meter -w '%{stderr}done\n'
</command>
</client>
# Verify data after the test has been "shot"
<verify>
<protocol crlf="yes" nonewline="yes">
POST /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 3
Content-Type: application/x-www-form-urlencoded
foo
</protocol>
<stderr mode="text">
Note: Unnecessary use of -X or --request, POST is already inferred.
done
</stderr>
</verify>
</testcase>