From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Cc: dsahern@gmail.com, Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH iproute2-next 2/7] ip/routel: follow help vs usage convention
Date: Fri, 7 Aug 2026 08:42:25 -0700 [thread overview]
Message-ID: <20260807154306.111200-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20260807154306.111200-1-stephen@networkplumber.org>
Similar to update to ip, put help on stdout and usage
on stderr.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
ip/routel | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/ip/routel b/ip/routel
index 09a90126..defe738c 100755
--- a/ip/routel
+++ b/ip/routel
@@ -11,10 +11,11 @@ import getopt
import subprocess
-def usage():
+def usage(help=False):
'''Print usage and exit'''
- print("Usage: {} [tablenr [raw ip args...]]".format(sys.argv[0]))
- sys.exit(64)
+ print("Usage: {} [tablenr [raw ip args...]]".format(sys.argv[0]),
+ file=sys.stdout if help else sys.stderr)
+ sys.exit(0 if help else 1)
def main():
@@ -23,12 +24,12 @@ def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "h46f:", ["help", "family="])
except getopt.GetoptError as err:
- print(err)
+ print(err, file=sys.stderr)
usage()
for opt, arg in opts:
if opt in ["-h", "--help"]:
- usage()
+ usage(True)
elif opt == '-6':
family = 'inet6'
elif opt == "-4":
--
2.53.0
next prev parent reply other threads:[~2026-08-07 15:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 15:42 [PATCH iproute2-next 0/7] cleanup help and exit codes Stephen Hemminger
2026-08-07 15:42 ` [PATCH iproute2-next 1/7] ip: follow Linux convention for help vs usage Stephen Hemminger
2026-08-07 15:42 ` Stephen Hemminger [this message]
2026-08-07 15:42 ` [PATCH iproute2-next 3/7] misc: put help to stdout and usage to stderr Stephen Hemminger
2026-08-07 15:42 ` [PATCH iproute2-next 4/7] netshaper: " Stephen Hemminger
2026-08-07 15:42 ` [PATCH iproute2-next 5/7] bridge: " Stephen Hemminger
2026-08-07 15:42 ` [PATCH iproute2-next 6/7] genl: " Stephen Hemminger
2026-08-07 15:42 ` [PATCH iproute2-next 7/7] tc: " 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=20260807154306.111200-3-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dsahern@gmail.com \
--cc=netdev@vger.kernel.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