Skip to content

cleanup help and exit codes

Stephen Hemminger netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7ip: follow Linux convention for help vs usageip/ip.c ip/ip6tunnel.c ip/ip_common.h +37 more+293 -2970 replies
2/7ip/routel: follow help vs usage conventionip/routel+6 -50 replies
3/7misc: put help to stdout and usage to stderrmisc/arpd.c misc/ifstat.c misc/nstat.c +1 more+41 -391 reply
4/7netshaper: put help to stdout and usage to stderrnetshaper/netshaper.c+16 -150 replies
5/7bridge: put help to stdout and usage to stderrbridge/bridge.c bridge/fdb.c bridge/link.c +5 more+58 -510 replies
6/7genl: put help to stdout and usage to stderrgenl/genl.c+8 -60 replies
7/7tc: put help to stdout and usage to stderrtc/e_bpf.c tc/f_basic.c tc/f_bpf.c +66 more+635 -4550 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH iproute2-next 0/7] cleanup help and exit codes

This series cleans up how iproute2 commands handle help and syntax errors. Before, ip help command and usage errors both output to stderr and had non-zero exit code. Now help outputs to stdout and exits with 0.

Since help and usage errors should not happen when iproute2 commands are scripted this should have little impact on users. There is no POSIX or other official standard for this; the design choices here follow the precedent in coreutils, etc.

Initial conversion was done by hand, but after that the same pattern was applied across all utilities with the aid of the "mechanical turk" (ie. Claude Opus).

Before:

$ ip help 2>/dev/null; echo $? # text is on stderr
255

After:

$ ip help >/dev/null; echo $? # text is on stdout
0

Usage output is unchanged:

$ ip bogus 2>/dev/null; echo $?
1

Note: a help command inside a batch file still exits immediately and following commands are not executed.

Example:

$ printf "help\nlink\n" | ./ip/ip -batch - ; echo $?
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
       ip [ -force ] -batch filename
...
0

Stephen Hemminger (7):
ip: follow Linux convention for help vs usage ip/routel: follow help vs usage convention
misc: put help to stdout and usage to stderr
netshaper: put help to stdout and usage to stderr
bridge: put help to stdout and usage to stderr
genl: put help to stdout and usage to stderr
tc: put help to stdout and usage to stderr

 bridge/bridge.c       | 20 ++++++++++----------
 bridge/fdb.c          | 18 +++++++++---------
 bridge/link.c         | 16 +++++++++++-----
 bridge/mdb.c          | 14 +++++++-------
 bridge/monitor.c      | 11 ++++++-----
 bridge/mst.c          | 10 +++++-----
 bridge/vlan.c         | 10 +++++-----
 bridge/vni.c          | 10 +++++-----
 genl/genl.c           | 14 ++++++++------
 ip/ip.c               | 15 ++++++++-------
 ip/ip6tunnel.c        | 12 ++++++------
 ip/ip_common.h        |  4 ++--
 ip/ipaddress.c        | 18 +++++++++---------
 ip/ipaddrlabel.c      | 10 +++++-----
 ip/ipfou.c            | 12 ++++++------
 ip/ipila.c            | 12 ++++++------
 ip/ipioam6.c          | 13 ++++++++-----
 ip/ipl2tp.c           | 21 ++++++++++++---------
 ip/iplink.c           | 40 ++++++++++++++++++++-------------------
 ip/iplink_amt.c       | 15 +++++----------
 ip/iplink_can.c       | 11 +++--------
 ip/iplink_dsa.c       |  4 ++--
 ip/iplink_hsr.c       | 11 +++--------
 ip/iplink_vxcan.c     | 11 +++--------
 ip/ipmacsec.c         | 32 +++++++++++++++----------------
 ip/ipmaddr.c          | 14 +++++++-------
 ip/ipmonitor.c        | 10 +++++-----
 ip/ipmptcp.c          | 10 +++++-----
 ip/ipmroute.c         | 14 +++++++-------
 ip/ipneigh.c          | 18 +++++++++---------
 ip/ipnetconf.c        | 10 +++++-----
 ip/ipnetns.c          | 10 +++++-----
 ip/ipnexthop.c        | 26 ++++++++++++-------------
 ip/ipntable.c         | 10 +++++-----
 ip/iproute.c          | 20 ++++++++++----------
 ip/iproute_lwtunnel.c | 33 +++++++++++++++++---------------
 ip/iprule.c           | 12 ++++++------
 ip/ipseg6.c           | 13 ++++++++-----
 ip/iptoken.c          | 13 +++++++------
 ip/iptunnel.c         | 12 ++++++------
 ip/iptuntap.c         | 12 ++++++------
 ip/ipvrf.c            | 10 +++++-----
 ip/ipxfrm.c           | 14 +++++++-------
 ip/link_veth.c        | 14 +++++---------
 ip/routel             | 11 ++++++-----
 ip/rtmon.c            | 10 +++++-----
 ip/tcp_metrics.c      | 12 ++++++------
 ip/xfrm_monitor.c     | 10 +++++-----
 ip/xfrm_policy.c      | 16 +++++++++-------
 ip/xfrm_state.c       | 26 +++++++++++++------------
 misc/arpd.c           | 12 +++++++-----
 misc/ifstat.c         | 44 +++++++++++++++++++++----------------------
 misc/nstat.c          | 11 ++++++-----
 misc/rtacct.c         | 13 ++++++-------
 netshaper/netshaper.c | 31 +++++++++++++++---------------
 tc/e_bpf.c            | 15 ++++++++++-----
 tc/f_basic.c          | 12 +++++++-----
 tc/f_bpf.c            | 12 +++++++-----
 tc/f_cgroup.c         | 16 ++++++++++------
 tc/f_flow.c           | 12 +++++++-----
 tc/f_flower.c         | 13 +++++++++----
 tc/f_fw.c             | 12 +++++++-----
 tc/f_matchall.c       | 12 +++++++-----
 tc/f_route.c          | 12 +++++++-----
 tc/f_u32.c            | 12 +++++++-----
 tc/m_action.c         | 23 ++++++++++------------
 tc/m_bpf.c            | 10 ++++++----
 tc/m_connmark.c       | 16 +++++++++-------
 tc/m_csum.c           | 18 ++++++++++--------
 tc/m_ct.c             | 12 +++++++-----
 tc/m_ctinfo.c         | 16 +++++++++-------
 tc/m_estimator.c      | 12 +++++++-----
 tc/m_gact.c           | 27 +++++++++++++++-----------
 tc/m_gate.c           | 14 ++++++++------
 tc/m_ife.c            | 16 +++++++++-------
 tc/m_mirred.c         | 14 ++++++++------
 tc/m_mpls.c           | 16 +++++++++-------
 tc/m_nat.c            | 22 +++++++++++++---------
 tc/m_pedit.c          | 22 ++++++++++++----------
 tc/m_police.c         | 10 ++++++----
 tc/m_sample.c         | 24 ++++++++++++-----------
 tc/m_simple.c         | 16 +++++++++-------
 tc/m_skbedit.c        | 17 ++++++++++-------
 tc/m_skbmod.c         | 16 +++++++++-------
 tc/m_tunnel_key.c     | 20 +++++++++++---------
 tc/m_vlan.c           | 24 ++++++++++++-----------
 tc/q_cake.c           | 12 +++++++-----
 tc/q_cbs.c            | 12 +++++++-----
 tc/q_choke.c          | 12 +++++++-----
 tc/q_clsact.c         | 14 ++++++++++----
 tc/q_codel.c          | 12 +++++++-----
 tc/q_drr.c            | 24 +++++++++++++----------
 tc/q_dualpi2.c        | 38 ++++++++++++++++++++-----------------
 tc/q_etf.c            | 12 +++++++-----
 tc/q_ets.c            | 29 ++++++++++++++++------------
 tc/q_fifo.c           | 13 ++++++++-----
 tc/q_fq.c             | 12 +++++++-----
 tc/q_fq_codel.c       | 12 +++++++-----
 tc/q_fq_pie.c         | 12 +++++++-----
 tc/q_gred.c           | 19 ++++++++++---------
 tc/q_hfsc.c           | 28 +++++++++++++++------------
 tc/q_hhf.c            | 12 +++++++-----
 tc/q_htb.c            | 19 ++++++++++++-------
 tc/q_ingress.c        | 14 ++++++++++----
 tc/q_mqprio.c         | 10 ++++++----
 tc/q_multiq.c         | 12 +++++++-----
 tc/q_netem.c          | 21 +++++++++++++--------
 tc/q_pie.c            | 12 +++++++-----
 tc/q_plug.c           | 13 ++++++++-----
 tc/q_prio.c           | 15 +++++++++------
 tc/q_qfq.c            | 26 ++++++++++++++++---------
 tc/q_red.c            | 12 +++++++-----
 tc/q_sfb.c            | 14 ++++++++++----
 tc/q_sfq.c            | 12 +++++++-----
 tc/q_skbprio.c        | 13 ++++++++-----
 tc/q_taprio.c         | 10 ++++++----
 tc/q_tbf.c            | 14 ++++++++------
 tc/tc.c               | 12 ++++++------
 tc/tc_class.c         | 20 ++++++++++++--------
 tc/tc_exec.c          |  6 +++---
 tc/tc_filter.c        | 31 +++++++++++++++++-------------
 tc/tc_monitor.c       | 11 ++++++-----
 tc/tc_qdisc.c         | 14 +++++++-------
 tc/tc_stab.c          | 13 +++++++------
 124 files changed, 1057 insertions(+), 868 deletions(-)
Signature · 1 line
2.53.0