Re: [patch] bashism in sh script



> On Fri, 1 Aug 2003, GoTaR wrote:
> 
> > There's no thing like $[..] to evaluate expressions in POSIX sh, it's
> > bash feature. sh uses $((..)) instead (and bash understands it too).
> > Here comes fix.
> 
> Does the next line work for you?  I mean this:
> 
>     if (( $A < 10 )); then A="0$A"; fi
> 
> I think it's a much worse case of non-portable code.  Have you tested your
> changes?

I think patch below make audio.in much more portable.
BTW, I don't see reason to substitute audio from audio.in.

-- 
Regards,
Andrew V. Samoilov.
--- audio.in~	Fri Dec 13 06:42:10 2002
+++ audio.in	Fri Aug  8 10:54:31 2003
@@ -15,13 +15,12 @@
 audiofs_list ()
 {
     echo "-r--r--r-- 1 0 0 0 Jan 1 0:00 CDDB"
-    cdparanoia -Q -d $1 2>&1 | grep '^[ 0-9][ 0-9][ 0-9]\.' | while true
+    cdparanoia -Q -d $1 2>&1 | grep '^[ 0-9][ 0-9][ 0-9]\.' | while read A B C
     do
-    read A B C || break
-    A=`echo $A | sed 's/\.//'`
-    SIZE=$[44+$B*2352]
-    if (( $A < 10 )); then A="0$A"; fi
-    echo "-r--r--r-- 1 0 0 $SIZE Jan 1 0:00 track-${A}.wav"
+	A=`echo $A | sed 's/\.//'`
+	SIZE=`expr 44 + $B \* 2352`
+	if test $A -lt 10 ; then A="0$A"; fi
+	echo "-r--r--r-- 1 0 0 $SIZE Jan 1 0:00 track-${A}.wav"
     done
 }
 
@@ -41,7 +40,7 @@
 }
 
 if [ ! -b "$2" ]
-    then
+then
     BASE=/dev/cdrom
 else
     BASE=$2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]