Re: [PATCH] eradicate bashisms in scripts/patch-kernel

2008-01-02 Thread Randy Dunlap
On Sat, 17 Nov 2007 21:51:25 +0100 Andreas Mohr wrote:

> Make the patch-kernel shell script sufficiently compatible with POSIX
> shells,
> i.e., remove bashisms from scripts/patch-kernel.
> This means that it now also works on dash 0.5.3-5
> and still works on bash 3.1dfsg-8.
> 
> Full changelog:
> - replaced non-standard "==" by standard "="
> - replaced non-standard "source" statement by POSIX "dot" command
> - use leading ./ on mktemp filename to force the tempfile to a local
>   directory, so that the search path is not used
> - replace bash syntax to remove leading dot by similar POSIX syntax
> - added missing (optional/not required) $ signs to shell variable names

The use of $(($x)) should not be needed with latest dash
anyway, Acked-by: Randy Dunlap <[EMAIL PROTECTED]>


> Signed-off-by: Andreas Mohr <[EMAIL PROTECTED]>
> ---
> Thanks for all comments! I might want to make sure to read more specs
> next time...
> Cowardly didn't dare to pre-add Randy's line, feel free to ack ;)
> 
> --- linux-2.6.23/scripts/patch-kernel.orig2007-11-17 21:26:47.0 
> +0100
> +++ linux-2.6.23/scripts/patch-kernel 2007-11-17 21:27:59.0 +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,
> @@ -182,10 +182,12 @@
>  }
>  
>  # set current VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION
> -TMPFILE=`mktemp .tmpver.XX` || { echo "cannot make temp file" ; exit 1; }
> +# force $TMPFILEs below to be in local directory: a slash character prevents
> +# the dot command from using the search path.
> +TMPFILE=`mktemp ./.tmpver.XX` || { 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,11 +204,7 @@
>  EXTRAVER=
>  if [ x$EXTRAVERSION != "x" ]
>  then
> - if [ ${EXTRAVERSION:0:1} == "." ]; then
> - EXTRAVER=${EXTRAVERSION:1}
> - else
> - EXTRAVER=$EXTRAVERSION
> - fi
> + EXTRAVER=${EXTRAVERSION#.}
>   EXTRAVER=${EXTRAVER%%[[:punct:]]*}
>   #echo "$PNAME: changing EXTRAVERSION from $EXTRAVERSION to $EXTRAVER"
>  fi
> @@ -251,16 +249,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 +295,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*\.*
> -

---
~Randy
desserts:  http://www.xenotime.net/linux/recipes/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] eradicate bashisms in scripts/patch-kernel

2008-01-02 Thread Randy Dunlap
On Sat, 17 Nov 2007 21:51:25 +0100 Andreas Mohr wrote:

 Make the patch-kernel shell script sufficiently compatible with POSIX
 shells,
 i.e., remove bashisms from scripts/patch-kernel.
 This means that it now also works on dash 0.5.3-5
 and still works on bash 3.1dfsg-8.
 
 Full changelog:
 - replaced non-standard == by standard =
 - replaced non-standard source statement by POSIX dot command
 - use leading ./ on mktemp filename to force the tempfile to a local
   directory, so that the search path is not used
 - replace bash syntax to remove leading dot by similar POSIX syntax
 - added missing (optional/not required) $ signs to shell variable names

The use of $(($x)) should not be needed with latest dash
anyway, Acked-by: Randy Dunlap [EMAIL PROTECTED]


 Signed-off-by: Andreas Mohr [EMAIL PROTECTED]
 ---
 Thanks for all comments! I might want to make sure to read more specs
 next time...
 Cowardly didn't dare to pre-add Randy's line, feel free to ack ;)
 
 --- linux-2.6.23/scripts/patch-kernel.orig2007-11-17 21:26:47.0 
 +0100
 +++ linux-2.6.23/scripts/patch-kernel 2007-11-17 21:27:59.0 +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,
 @@ -182,10 +182,12 @@
  }
  
  # set current VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION
 -TMPFILE=`mktemp .tmpver.XX` || { echo cannot make temp file ; exit 1; }
 +# force $TMPFILEs below to be in local directory: a slash character prevents
 +# the dot command from using the search path.
 +TMPFILE=`mktemp ./.tmpver.XX` || { 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,11 +204,7 @@
  EXTRAVER=
  if [ x$EXTRAVERSION != x ]
  then
 - if [ ${EXTRAVERSION:0:1} == . ]; then
 - EXTRAVER=${EXTRAVERSION:1}
 - else
 - EXTRAVER=$EXTRAVERSION
 - fi
 + EXTRAVER=${EXTRAVERSION#.}
   EXTRAVER=${EXTRAVER%%[[:punct:]]*}
   #echo $PNAME: changing EXTRAVERSION from $EXTRAVERSION to $EXTRAVER
  fi
 @@ -251,16 +249,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 +295,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*\.*
 -

---
~Randy
desserts:  http://www.xenotime.net/linux/recipes/
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] eradicate bashisms in scripts/patch-kernel

2007-11-17 Thread Andreas Mohr
Make the patch-kernel shell script sufficiently compatible with POSIX
shells,
i.e., remove bashisms from scripts/patch-kernel.
This means that it now also works on dash 0.5.3-5
and still works on bash 3.1dfsg-8.

Full changelog:
- replaced non-standard "==" by standard "="
- replaced non-standard "source" statement by POSIX "dot" command
- use leading ./ on mktemp filename to force the tempfile to a local
  directory, so that the search path is not used
- replace bash syntax to remove leading dot by similar POSIX syntax
- added missing (optional/not required) $ signs to shell variable names

Signed-off-by: Andreas Mohr <[EMAIL PROTECTED]>
---
Thanks for all comments! I might want to make sure to read more specs
next time...
Cowardly didn't dare to pre-add Randy's line, feel free to ack ;)

--- linux-2.6.23/scripts/patch-kernel.orig  2007-11-17 21:26:47.0 
+0100
+++ linux-2.6.23/scripts/patch-kernel   2007-11-17 21:27:59.0 +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,
@@ -182,10 +182,12 @@
 }
 
 # set current VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION
-TMPFILE=`mktemp .tmpver.XX` || { echo "cannot make temp file" ; exit 1; }
+# force $TMPFILEs below to be in local directory: a slash character prevents
+# the dot command from using the search path.
+TMPFILE=`mktemp ./.tmpver.XX` || { 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,11 +204,7 @@
 EXTRAVER=
 if [ x$EXTRAVERSION != "x" ]
 then
-   if [ ${EXTRAVERSION:0:1} == "." ]; then
-   EXTRAVER=${EXTRAVERSION:1}
-   else
-   EXTRAVER=$EXTRAVERSION
-   fi
+   EXTRAVER=${EXTRAVERSION#.}
EXTRAVER=${EXTRAVER%%[[:punct:]]*}
#echo "$PNAME: changing EXTRAVERSION from $EXTRAVERSION to $EXTRAVER"
 fi
@@ -251,16 +249,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 +295,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*\.*
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] eradicate bashisms in scripts/patch-kernel

2007-11-17 Thread Andreas Mohr
Make the patch-kernel shell script sufficiently compatible with POSIX
shells,
i.e., remove bashisms from scripts/patch-kernel.
This means that it now also works on dash 0.5.3-5
and still works on bash 3.1dfsg-8.

Full changelog:
- replaced non-standard == by standard =
- replaced non-standard source statement by POSIX dot command
- use leading ./ on mktemp filename to force the tempfile to a local
  directory, so that the search path is not used
- replace bash syntax to remove leading dot by similar POSIX syntax
- added missing (optional/not required) $ signs to shell variable names

Signed-off-by: Andreas Mohr [EMAIL PROTECTED]
---
Thanks for all comments! I might want to make sure to read more specs
next time...
Cowardly didn't dare to pre-add Randy's line, feel free to ack ;)

--- linux-2.6.23/scripts/patch-kernel.orig  2007-11-17 21:26:47.0 
+0100
+++ linux-2.6.23/scripts/patch-kernel   2007-11-17 21:27:59.0 +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,
@@ -182,10 +182,12 @@
 }
 
 # set current VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION
-TMPFILE=`mktemp .tmpver.XX` || { echo cannot make temp file ; exit 1; }
+# force $TMPFILEs below to be in local directory: a slash character prevents
+# the dot command from using the search path.
+TMPFILE=`mktemp ./.tmpver.XX` || { 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,11 +204,7 @@
 EXTRAVER=
 if [ x$EXTRAVERSION != x ]
 then
-   if [ ${EXTRAVERSION:0:1} == . ]; then
-   EXTRAVER=${EXTRAVERSION:1}
-   else
-   EXTRAVER=$EXTRAVERSION
-   fi
+   EXTRAVER=${EXTRAVERSION#.}
EXTRAVER=${EXTRAVER%%[[:punct:]]*}
#echo $PNAME: changing EXTRAVERSION from $EXTRAVERSION to $EXTRAVER
 fi
@@ -251,16 +249,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 +295,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*\.*
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/