public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: Konstantin Khlebnikov <koct9i@gmail.com>
To: Michal Marek <mmarek@suse.cz>,
	linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org
Cc: Paul Bolle <pebolle@tiscali.nl>,
	Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PATCH v2 2/4] scripts/config: add option for changing output for undefined options
Date: Mon, 01 Sep 2014 11:16:32 +0400	[thread overview]
Message-ID: <20140901071632.28909.31322.stgit@zurg> (raw)
In-Reply-To: <20140901065916.28909.35097.stgit@zurg>

This patch adds command line option '--if-undef' which replaces string 'undef'
in output of next command '--state' with whatever you want.

Also it adds grep key -s to suppress error messages about nonexistent file.

Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
---
 scripts/config |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/scripts/config b/scripts/config
index 026aeb4..178652c 100755
--- a/scripts/config
+++ b/scripts/config
@@ -6,6 +6,9 @@ myname=${0##*/}
 # If no prefix forced, use the default CONFIG_
 CONFIG_="${CONFIG_-CONFIG_}"
 
+# Output for undefined options
+UNDEF="undef"
+
 usage() {
 	cat >&2 <<EOL
 Manipulate options in a .config file from the command line.
@@ -34,6 +37,7 @@ commands:
 options:
 	--file config-file   .config file to change (default .config)
 	--keep-case|-k       Keep next symbols' case (dont' upper-case it)
+	--if-undef string    Print this string instead of state "undef"
 
 $myname doesn't check the validity of the .config file. This is done at next
 make time.
@@ -152,6 +156,11 @@ while [ "$1" != "" ] ; do
 		B=$ARG
 		shift 2
 		;;
+	--if-undef)
+		UNDEF=$1
+		shift
+		continue
+		;;
 	-*)
 		checkarg "$1"
 		shift
@@ -185,12 +194,12 @@ while [ "$1" != "" ] ; do
 		;;
 
 	--state|-s)
-		if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
+		if grep -sq "# ${CONFIG_}$ARG is not set" $FN ; then
 			echo n
 		else
-			V="$(grep "^${CONFIG_}$ARG=" $FN)"
+			V="$(grep -s "^${CONFIG_}$ARG=" $FN)"
 			if [ $? != 0 ] ; then
-				echo undef
+				echo "${UNDEF}"
 			else
 				V="${V/#${CONFIG_}$ARG=/}"
 				V="${V/#\"/}"


  parent reply	other threads:[~2014-09-01  7:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-01  7:16 [PATCH v2 0/4] kconfig: store default ARCH in .config Konstantin Khlebnikov
2014-09-01  7:16 ` [PATCH v2 1/4] kconfig: save values imported from environment into config file Konstantin Khlebnikov
2014-09-01  7:16 ` Konstantin Khlebnikov [this message]
2014-09-01  7:16 ` [PATCH v2 3/4] kconfig: get target architecture from " Konstantin Khlebnikov
2014-09-01  7:16 ` [PATCH v2 4/4] kconfig: link CONFIG_CROSS_COMPILE with environment variable Konstantin Khlebnikov
2014-09-03 21:11   ` Paul Bolle
2014-09-04  5:23     ` Konstantin Khlebnikov
2014-09-01  7:24 ` [PATCH v2 0/4] kconfig: store default ARCH in .config Geert Uytterhoeven
2014-09-01  7:35   ` Konstantin Khlebnikov
2014-10-27 17:20 ` Konstantin Khlebnikov
2014-12-10 20:24   ` Paul Bolle

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=20140901071632.28909.31322.stgit@zurg \
    --to=koct9i@gmail.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.cz \
    --cc=pebolle@tiscali.nl \
    /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