public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] new: validate groups when creating new test
@ 2017-07-28  6:25 Eryu Guan
  2017-08-03 11:53 ` Brian Foster
  0 siblings, 1 reply; 2+ messages in thread
From: Eryu Guan @ 2017-07-28  6:25 UTC (permalink / raw)
  To: fstests; +Cc: sandeen, Eryu Guan

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-03 11:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-28  6:25 [PATCH] new: validate groups when creating new test Eryu Guan
2017-08-03 11:53 ` Brian Foster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox