From: Dmitri Seletski <drjoms@gmail.com>
To: David Laight <david.laight.linux@gmail.com>,
Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org
Subject: Re: "ip help" output is an error
Date: Mon, 22 Jun 2026 11:39:46 +0100 [thread overview]
Message-ID: <e07eeab3-9cb2-4cdd-9831-0851c278ac43@gmail.com> (raw)
In-Reply-To: <20260622084925.6f3dfc4f@pumpkin>
Hello David,(sorry for duplicate, I keep on forgetting to turn off HTML)
Yes, user could do the redirection, but it's less convenient and
counterintuitive. IMHO, it's just wrong.
Once user has done "ip help" - IMHO, exit code should be 0. Because user
did run a command and it correctly executed with a reasonable
results(provided help text).
And if exit code is 0 - then it reasonably stands that output data is
standard output and not an error.
"it do exit(0) is likely cause new scripts to fail on old systems." - do
I understand correctly, concern is that existing scripts that depend on
current behavior will fail?
First of all, I am guessing that there are not many scripts that depend
on "ip help".
Second of all, if there are such scripts and we follow this logic - do
we ever patch anything? Since any script out there can depend on broken
behavior that will be patched?
Third of all, people who wrote such scripts, should have reported bug
here in the first place. But it's neither here nor there.
Do I fail to see a bigger picture here? Cause I feel silly talking in
this mailing list.(I submitted a change for this issue about half a day ago)
Kind Regards
Dmitri Seletski
On 6/22/26 08:49, David Laight wrote:
> On Sun, 21 Jun 2026 08:21:05 -0700
> Stephen Hemminger <stephen@networkplumber.org> wrote:
>
>> On Sat, 20 Jun 2026 10:36:31 +0100
>> Dmitri Seletski <drjoms@gmail.com> wrote:
>>
>>> Hello iproute2 maintainers,
>>>
>>> I am reporting an inconsistency regarding the exit status of the ip help
>>> command.
>>>
>>> Current Behavior:
>>> When running ip help, the command prints the help documentation to
>>> stdout, but exits with a non-zero status (error). This causes issues in
>>> shell scripts that rely on exit codes for control flow.
>>>
>>> Steps to reproduce:
>>> bash
>>>
>>> # This returns "FAIL" because the exit code is non-zero
>>> if ip help > /dev/null; then
>>> echo "SUCCESS"
>>> else
>>> echo "FAIL"
>>> fi
>>>
>>> Expected Behavior:
>>> Since the command successfully performs the requested task (displaying
>>> help information) and does not encounter a system error, it should
>>> return an exit code of 0.
>>>
>>> Context:
>>> This behavior breaks standard Bash logic for automation. For example:
>>> ip help && echo "This will not execute"
>>>
>>> "ip help |grep br" - this will bring no result.
>>>
>>> Current version tested: iproute2-6.19.0
>>>
>>> Thank you for your time and for maintaining this tool.
>>>
>>> Regards,
>>> Dmitri Seletski
>>>
>>>
>> Yes iproute2 doesn't do a great job of handling error codes
>> with usage vs help. Its a bug and no one has bothered to fix it.
>>
> The version I've got does write(2, "Usage...", 972); exit(-1);
> Changing it to do write(1, ...) is likely to break scripts, and making
> it do exit(0) is likely cause new scripts to fail on old systems.
>
> The 'grep' works fine if you redirect stderr to stdout.
>
> The exit(-1) is a bug; the parameter is only 8 bits and the high bit
> is expected to be used to indicate abnormal termination (eg by a signal).
> That should probably be changed to exit(1), there doesn't seem to be
> a standard way to differentiate between command line errors and
> operational ones.
>
> David
>
next prev parent reply other threads:[~2026-06-22 10:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-20 9:36 "ip help" output is an error Dmitri Seletski
2026-06-21 15:21 ` Stephen Hemminger
2026-06-21 21:51 ` Dmitri Seletski
2026-06-22 7:49 ` David Laight
2026-06-22 10:39 ` Dmitri Seletski [this message]
[not found] ` <069b13e1-f689-410b-bd40-b5e5831b67e7@gmail.com>
2026-06-22 14:57 ` [PATCH iproute2-next] "ip help" wrong output, exit code Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e07eeab3-9cb2-4cdd-9831-0851c278ac43@gmail.com \
--to=drjoms@gmail.com \
--cc=david.laight.linux@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox