Netdev List
 help / color / mirror / Atom feed
* "ip help" output is an error
@ 2026-06-20  9:36 Dmitri Seletski
  2026-06-21 15:21 ` Stephen Hemminger
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitri Seletski @ 2026-06-20  9:36 UTC (permalink / raw)
  To: netdev


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


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH iproute2-next] "ip help" wrong output, exit code.
@ 2026-06-21 21:56 Dmitri Seletski
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitri Seletski @ 2026-06-21 21:56 UTC (permalink / raw)
  To: netdev

Changed output of "ip help" from standard error to standard output. And 
Exit is now 0 instead of -1. "ip help|grep bridge" - now gives bridge 
syntax instead of flooding user with everything from "ip help".
---
ip/ip.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ip/ip.c b/ip/ip.c
index e4b71bde..4627b61c 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -56,7 +56,7 @@ static void usage(void) __attribute__((noreturn));

static void usage(void)
{
-fprintf(stderr,
+fprintf(stdout,
"Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }\n"
"       ip [ -force ] -batch filename\n"
"where  OBJECT := { address | addrlabel | fou | help | ila | ioam | l2tp 
| link |\n"
@@ -72,7 +72,7 @@ static void usage(void)
"                    -o[neline] | -t[imestamp] | -ts[hort] | -b[atch] 
[filename] |\n"
"                    -rc[vbuf] [size] | -n[etns] name | -N[umeric] | 
-a[ll] |\n"
"                    -c[olor]}\n");
-exit(-1);
+exit(0);
}

static int do_help(int argc, char **argv)
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-06-22 16:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
     [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
2026-06-22 16:44       ` David Laight
  -- strict thread matches above, loose matches on Subject: below --
2026-06-21 21:56 Dmitri Seletski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox