From: Folderol on
The script below works perfectly in bash, but if I try to run it on a
system with dash I get the following error:

Start_Midisport.sh: 21: [[: not found

Can anyone suggest what I should do to get it to work equally well in
either shell?


#!/bin/bash

# echo's can be removed -just for testing

name="MidiSport"
lsusb | cat | while read line
do
if [[ "$line" =~ "$name" ]]
then
echo $line
result=${line#'Bus '}
busnumber=${result%' Device'*}
result=${result#*'Device '}
devicenumber=${result%': ID'*}
echo $busnumber
echo $devicenumber
result="sudo fxload
-I /usr/local/share/usb/maudio/MidiSport2x2.ihx -D /dev/bus/usb/"$busnumber"/"$devicenumber
echo $result
exec $result
fi
done
echo


--
Will J G
From: Chris Davies on
Folderol <folderol(a)ukfsn.org> wrote:
> The script below works perfectly in bash, but if I try to run it on a
> system with dash I get the following error:

> Start_Midisport.sh: 21: [[: not found

> Can anyone suggest what I should do to get it to work equally well in
> either shell?

How do you run it (the exact command, please)?
Chris
From: Folderol on
On Fri, 12 Mar 2010 15:23:22 +0000
Chris Davies <chris-usenet(a)roaima.co.uk> wrote:

> Folderol <folderol(a)ukfsn.org> wrote:
> > The script below works perfectly in bash, but if I try to run it on a
> > system with dash I get the following error:
>
> > Start_Midisport.sh: 21: [[: not found
>
> > Can anyone suggest what I should do to get it to work equally well in
> > either shell?
>
> How do you run it (the exact command, please)?
> Chris

As an embedded desktop command:
sh Start_Midisport.sh

but when testing, in a terminal either:
bash Start_Midisport.sh

or:
dash Start_Midisport.sh

--
Will J G
From: unruh on
On 2010-03-12, Folderol <folderol(a)ukfsn.org> wrote:
> On Fri, 12 Mar 2010 15:23:22 +0000
> Chris Davies <chris-usenet(a)roaima.co.uk> wrote:
>
>> Folderol <folderol(a)ukfsn.org> wrote:
>> > The script below works perfectly in bash, but if I try to run it on a
>> > system with dash I get the following error:
>>
>> > Start_Midisport.sh: 21: [[: not found
>>
>> > Can anyone suggest what I should do to get it to work equally well in
>> > either shell?

[[ is an internal command in bash. I guess it is not in dash.
complain to the writers of dash.



From: Richard Kettlewell on
unruh <unruh(a)wormhole.physics.ubc.ca> writes:

> On 2010-03-12, Folderol <folderol(a)ukfsn.org> wrote:
>> On Fri, 12 Mar 2010 15:23:22 +0000
>> Chris Davies <chris-usenet(a)roaima.co.uk> wrote:
>>
>>> Folderol <folderol(a)ukfsn.org> wrote:
>>> > The script below works perfectly in bash, but if I try to run it on a
>>> > system with dash I get the following error:
>>>
>>> > Start_Midisport.sh: 21: [[: not found
>>>
>>> > Can anyone suggest what I should do to get it to work equally well in
>>> > either shell?
>
> [[ is an internal command in bash. I guess it is not in dash.
> complain to the writers of dash.

It's a Bashism, i.e. not a standard (in the POSIX sense) shell feature.

--
http://www.greenend.org.uk/rjk/