public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH/RFC] eradicate bashisms in scripts/patch-kernel
@ 2007-10-31 21:13 Andreas Mohr
  2007-10-31 22:24 ` Randy Dunlap
  2007-11-17 17:24 ` [PATCH/RFC] " Adrian Bunk
  0 siblings, 2 replies; 21+ messages in thread
From: Andreas Mohr @ 2007-10-31 21:13 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: Andrew Morton, Linux Kernel Mailing List

Hello,

I was non-mildly horrified to find that the rather widely used patch-kernel
script seems to rely on bash despite specifying the interpreter as #!/bin/sh,
since my dash-using Debian install choked on it.

Thus I'm delivering a first, preliminary, non-reviewed change to make
patch-kernel (a little bit more?) POSIX-compatible. It now survives both
a dash and a bash run.

If this mail goes through relatively unscathed, then it might be a good
idea to plant it into -mm via a follow-up mail.

Comments?

- replaced "==" by "="
- the "source" statement most likely needs the ./ prepended, as can be
gathered from e.g. http://osdir.com/ml/colinux.devel/2005-12/msg00036.html
- the newly replaced sed expression below: is it ok? correct? strict enough?

Thanks,

Andreas Mohr

(who's strongly hoping that submitting a patch for this thingy doesn't
automatically equal becoming "maintainer for life" for it ;)

--- linux-2.6.23/scripts/patch-kernel	2007-10-31 21:55:26.000000000 +0100
+++ linux-2.6.23/scripts/patch-kernel.dash	2007-10-31 21:58:37.000000000 +0100
@@ -65,7 +65,7 @@
 patchdir=${2-.}
 stopvers=${3-default}
 
-if [ "$1" == -h -o "$1" == --help -o ! -r "$sourcedir/Makefile" ]; then
+if [ "$1" = "-h" -o "$1" = "--help" -o ! -r "$sourcedir/Makefile" ]; then
 cat << USAGE
 usage: $PNAME [-h] [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ]
   source directory defaults to /usr/src/linux,
@@ -185,7 +185,7 @@
 TMPFILE=`mktemp .tmpver.XXXXXX` || { echo "cannot make temp file" ; exit 1; }
 grep -E "^(VERSION|PATCHLEVEL|SUBLEVEL|EXTRAVERSION)" $sourcedir/Makefile > $TMPFILE
 tr -d [:blank:] < $TMPFILE > $TMPFILE.1
-source $TMPFILE.1
+. ./$TMPFILE.1
 rm -f $TMPFILE*
 if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ]
 then
@@ -202,13 +202,7 @@
 EXTRAVER=
 if [ x$EXTRAVERSION != "x" ]
 then
-	if [ ${EXTRAVERSION:0:1} == "." ]; then
-		EXTRAVER=${EXTRAVERSION:1}
-	else
-		EXTRAVER=$EXTRAVERSION
-	fi
-	EXTRAVER=${EXTRAVER%%[[:punct:]]*}
-	#echo "$PNAME: changing EXTRAVERSION from $EXTRAVERSION to $EXTRAVER"
+	EXTRAVER=`echo $EXTRAVERSION|sed -s 's/^[\.]\?\([^[:punct:]]*\).*/\1/'`
 fi
 
 #echo "stopvers=$stopvers"
@@ -251,16 +245,16 @@
 do
     CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
     EXTRAVER=
-    if [ $stopvers == $CURRENTFULLVERSION ]; then
+    if [ $stopvers = $CURRENTFULLVERSION ]; then
         echo "Stopping at $CURRENTFULLVERSION base as requested."
         break
     fi
 
-    SUBLEVEL=$((SUBLEVEL + 1))
+    SUBLEVEL=$(( $SUBLEVEL + 1 ))
     FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
     #echo "#___ trying $FULLVERSION ___"
 
-    if [ $((SUBLEVEL)) -gt $((STOPSUBLEVEL)) ]; then
+    if [ $SUBLEVEL -gt $STOPSUBLEVEL ]; then
 	echo "Stopping since sublevel ($SUBLEVEL) is beyond stop-sublevel ($STOPSUBLEVEL)"
 	exit 1
     fi
@@ -297,7 +291,7 @@
 if [ x$gotac != x ]; then
   # Out great user wants the -ac patches
 	# They could have done -ac (get latest) or -acxx where xx=version they want
-	if [ $gotac == "-ac" ]; then
+	if [ $gotac = "-ac" ]; then
 	  # They want the latest version
 		HIGHESTPATCH=0
 		for PATCHNAMES in $patchdir/patch-${CURRENTFULLVERSION}-ac*\.*

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

end of thread, other threads:[~2011-04-21 11:36 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-31 21:13 [PATCH/RFC] eradicate bashisms in scripts/patch-kernel Andreas Mohr
2007-10-31 22:24 ` Randy Dunlap
2007-11-01 12:11   ` Andreas Mohr
2007-11-01 15:24     ` Randy Dunlap
2007-11-01 22:16       ` Andreas Mohr
2007-11-01 23:08         ` Randy Dunlap
2007-11-02  2:01           ` Herbert Xu
2007-11-02 20:09             ` Andreas Mohr
2007-11-02 20:17               ` Randy Dunlap
2007-11-05 19:58                 ` Andreas Mohr
2007-11-14 22:46                   ` Randy Dunlap
2007-11-17 16:33                     ` Andreas Mohr
2007-11-17 16:43                       ` Herbert Xu
2007-11-17 17:28                       ` Sam Ravnborg
2007-11-17 20:51                         ` [PATCH] " Andreas Mohr
2008-01-02 23:00                           ` Randy Dunlap
2011-04-03 18:58                           ` [PATCH] " Andreas Mohr
2011-04-03 19:40                             ` Randy Dunlap
2011-04-21 11:36                               ` Andreas Mohr
2011-04-04 12:59                             ` Michal Marek
2007-11-17 17:24 ` [PATCH/RFC] " Adrian Bunk

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