mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bhaskar Chowdhury <unixbhaskar@gmail.com>
To: unixbhaskar@gmail.com, linux-kernel@vger.kernel.org
Cc: paulmck@kernel.org
Subject: [PATCH V2] tools: rcu: Added check for argument and usage function
Date: Tue, 10 Jan 2023 16:46:34 +0530	[thread overview]
Message-ID: <20230110111634.26371-1-unixbhaskar@gmail.com> (raw)

Thought it would be good to have some formatted way of letting user know
about, how to use this script properly and added some checking too for missing
argument.


cc: paulmck@kernel.org

Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com>
---
 Changes from V1 : Flip the code blocks of function for logical evaluation
                   and strip off the path from script when displaying help
 tools/rcu/extract-stall.sh | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/tools/rcu/extract-stall.sh b/tools/rcu/extract-stall.sh
index e565697c9f90..6ea76230f72f 100644
--- a/tools/rcu/extract-stall.sh
+++ b/tools/rcu/extract-stall.sh
@@ -1,11 +1,24 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0+
 #
-# Extract any RCU CPU stall warnings present in specified file.
-# Filter out clocksource lines.  Note that preceding-lines excludes the
-# initial line of the stall warning but trailing-lines includes it.
-#
-# Usage: extract-stall.sh dmesg-file [ preceding-lines [ trailing-lines ] ]
+# This is a usage function to spit out information about properly use this
+# script
+
+usage() {
+
+   echo  Extract any RCU CPU stall warnings present in specified file.
+   echo  Filter out clocksource lines.  Note that preceding-lines excludes the
+   echo  initial line of the stall warning but trailing-lines includes it.
+
+   echo Usage: $(basename $0) dmesg-file [ preceding-lines [ trailing-lines ] ]
+}
+
+# Terminate the script, if the argument is missing
+
+if [ $# -eq 0 ];then
+	usage
+	exit 1
+fi

 echo $1
 preceding_lines="${2-3}"
--
2.38.2


             reply	other threads:[~2023-01-10 11:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 11:16 Bhaskar Chowdhury [this message]
2023-01-10 17:39 ` Paul E. McKenney

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=20230110111634.26371-1-unixbhaskar@gmail.com \
    --to=unixbhaskar@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@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

all inboxes | Powered by JetHome®