Gustin Johnson wrote:
>> I tried #!/bin/sh and #!/bin/bash with 64 Studio 3.0-beta3 and both were
>> not fine with arrays. [snip]
>>
>
> /bin/sh is a sym link to dash, which is not as feature rich as Bash.
> Until your question I had forgotten that Ubuntu had made it the /bin/sh
> replacement back with the 6.10 version. I had to rewrite a few scripts
> back then.
>
> Anyway, some more info can be found on wikipedia.
>
> What is the problem you are experiencing? I can verify that arrays are
> working as expected from both Ubuntu 8.04 and 64Studio 3 beta which is
> not surprising given that both are using identical versions of bash.
>
> Try the following one line at a time from a shell, it should not matter
> if you are root:
>
> declare -a sourcedir=( "/etc" "/usr/local" "/var/log" )
>
> elements="${#sourcedir[*]}"
>
> for (( i = 0 ; i < $elements ; i++ )) ; do echo ${sourcedir[$i]} ; done
>
> Do you see any errors at any stage? If so what are they? If not what
> is the output from the final line?
>
> If you do see an error, what version of bash are you using ("bash
> - --version" will tell you)?
>
spinymouse-s...@64studio:~$ ls -l | grep sh$
-rw-r--r-- 1 spinymouse-sudo spinymouse-sudo 187 2009-10-14 03:21
test.bin\bash
-rw-r--r-- 1 spinymouse-sudo spinymouse-sudo 185 2009-10-14 03:20
test.bin\sh
spinymouse-s...@64studio:~$ cat test.bin\\sh
#!/bin/sh
declare -a sourcedir=( "/etc" "/usr/local" "/var/log" )
elements="${#sourcedir[*]}"
for (( i = 0 ; i < $elements ; i++ )) ; do echo ${sourcedir[$i]} ; done
bash --version
spinymouse-s...@64studio:~$ cat test.bin\\bash
#!/bin/bash
declare -a sourcedir=( "/etc" "/usr/local" "/var/log" )
elements="${#sourcedir[*]}"
for (( i = 0 ; i < $elements ; i++ )) ; do echo ${sourcedir[$i]} ; done
bash --version
spinymouse-s...@64studio:~$ sh test.bin?sh
test.bin\sh: 2: Syntax error: "(" unexpected
spinymouse-s...@64studio:~$ sh test.bin?bash
test.bin\bash: 2: Syntax error: "(" unexpected
spinymouse-s...@64studio:~$ bash --version
GNU bash, version 3.2.39(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
spinymouse-s...@64studio:~$
> In my experience, Bash is the most common, followed by ash
The problem that bash for Ubuntu doesn't know arrays is known. IIUC bash
= POSIX ¬ POSIX = no arrays
Ralf
_______________________________________________
64studio-users mailing list
[email protected]
http://lists.64studio.com/mailman/listinfo/64studio-users