From: Nix on 13 Mar 2010 11:13 On 12 Mar 2010, Mark Hobley spake thusly: > Some of use the terms differently, but I would interpret a bashism as being > any syntax element that is not supported in the System V Unix shell. So a > kshism may also be called a bashism. I call things bashisms if they're supported by bash but not other major shells (bar zsh, which supports everything), in particular the shell defined by POSIX. I don't give a damn about the System V Unix shell per se anymore. Nobody uses it.
From: Folderol on 13 Mar 2010 13:09 On 12 Mar 2010 22:05:31 GMT "Chris F.A. Johnson" <cfajohnson(a)gmail.com> wrote: > On 2010-03-12, Folderol 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 > > Dash is a very basic POSIX shell. [[ ... ]] is not part of the > POSIX shell. > > > 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 > > Why do you have 'cat' in there? > > > do > > if [[ "$line" =~ "$name" ]] > > To test whether one string contains another, use case: > > case $line in > *"$name"*) # Do whatever > ;; > *) ;; # Do something else (or nothing) > esac > > > then > > echo $line > > result=${line#'Bus '} > > busnumber=${result%' Device'*} > > result=${result#*'Device '} > > You don't need the single quotes. > > > 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 The whole thing was rather cobbled together from looking up bits all over the net (cos I don't have much idea what I'm doing). Most of the stuff I found didn't really explain how things work so I had to keep chopping and changing until it seemed to hang together. I wouldn't be at all surprised to find that extracting the bus and device numbers could be done more neatly. It certainly looks messy to me. However, I'm a musician first and a programmer last, so once I get things in a usable state it's hard for me to maintain the impetus to improve things! -- Will J G
From: Chris Davies on 16 Mar 2010 10:11 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 Chris Davies <chris-usenet(a)roaima.co.uk> asked: > How do you run it (the exact command, please)? Folderol replied: > sh Start_Midisport.sh > bash Start_Midisport.sh > dash Start_Midisport.sh Here you're using three potentially different shells, of which at least one doesn't understand the [[ ... ]] syntax. All three invocations ignore the #! instruction on the first line of your script. The obvious fix is to make the script executable and treat it as such: ./Start_Midisport.sh If you only have dash on your target device there's no point using bash constructs and expecting them to work. Instead, you need to make the script a dash script, and replace the [[ ... ]] construct with something that works within dash. Chris
First
|
Prev
|
Pages: 1 2 3 4 Prev: Skype can't see working Webcam Next: Problem installing collabtive on LAMP server |