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

Stephen Hemminger <[email protected]>
Newsgroups org.kernel.vger.netdev
Message-ID <[email protected]>
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(-)

-- 
2.53.0
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.