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
@@ -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=
- 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