public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Eryu Guan <eguan@redhat.com>
To: fstests@vger.kernel.org
Cc: sandeen@sandeen.net, Eryu Guan <eguan@redhat.com>
Subject: [PATCH] new: validate groups when creating new test
Date: Fri, 28 Jul 2017 14:25:22 +0800	[thread overview]
Message-ID: <20170728062522.16916-1-eguan@redhat.com> (raw)

Allow only lower case letters, digits, spaces and underscore when
adding groups, give prompt if there's any not-allowed characters.
Also remove redundant spaces between groups.

Signed-off-by: Eryu Guan <eguan@redhat.com>
---
 new | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/new b/new
index eb7da0ff463b..4eacccd3bf8b 100755
--- a/new
+++ b/new
@@ -239,7 +239,7 @@ then
 
     while true
     do
-	echo -n "Add to group(s) [other] (? for list): "
+	echo -n "Add to group(s) [other] (separate by space, ? for list): "
 	read ans
 	[ -z "$ans" ] && ans=other
 	if [ "X$ans" = "X?" ]
@@ -254,7 +254,17 @@ then
 	    lst=`for word in $grpl; do echo $word; done | sort| uniq `
 	    echo $lst
 	else
-	    break
+	    # only allow lower cases, spaces, digits and underscore in group
+	    inval=`echo $ans | tr -d '[:lower:][:space:][:digit:]_'`
+	    if [ "$inval" != "" ]; then
+		echo "Invalid characters in group(s): $inval"
+		echo "Only lower cases, digits and underscore are allowed in groups, separated by space"
+		continue
+	    else
+		# remove redundant spaces/tabs
+		ans=`echo "$ans" | sed 's/\s\+/ /g'`
+		break
+	    fi
 	fi
     done
 else
-- 
2.13.3


             reply	other threads:[~2017-07-28  6:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-28  6:25 Eryu Guan [this message]
2017-08-03 11:53 ` [PATCH] new: validate groups when creating new test Brian Foster

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=20170728062522.16916-1-eguan@redhat.com \
    --to=eguan@redhat.com \
    --cc=fstests@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /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