-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ralf Mardorf wrote:
<snip>
>>>
>>> Array variables are fine for e.g. c like shells and even for pseudo
>>> Bourne shells, e.g. on Suse or Debian, but not for real POSIX, e.g.
>>> /bin/sh on Ubuntu, anyway I'll take a look at those guides too.
>>>
>>
>> That is a good point. I work with OpenWRT a lot (not just on Linksys
>> routers, but on x86 SBCs that we use a lot with our customers). Out of
>> the box OpenWRT does not have bash so we have to be mindful of the
>> differences. Arrays are so very nice to have, but Bash may not always
>> be available. There are a number of these features with Bash that are
>> specific to Bash.
>>
>> Having said that, the vast majority of my scripts are run on Linux or on
>> Windows via Cygwin, so I make use of those handy features when I can.
>> For any scripts for a full Linux distribution, I can count on Bash being
>> there (in fact on every modern distro that I have seen, /bin/sh is
>> usually just a symlink to /bin/bash).
>>
>
> I tried #!/bin/sh and #!/bin/bash with 64 Studio 3.0-beta3 and both were
> not fine with arrays. I needed half of a day to search the web and only
/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)?
> one guy has written that there's a POSIX standard, so instead of using
> arrays there's a trick with normal variables to simulate an array: eval
> x="\${y${z}}"
I have never used this method, no idea if it works or not.
> Because I know arrays from other languages, I don't need to learn what
> an array is and only need to learn this trick, but I guess for somebody
> who don't know what an array is and who has to learn this trick in
> addition, it would be very hard. Most guides use c like commands, arrays
> etc..
> I decided to learn POSIX shell script, maybe I should use another shell,
> resp. install a bash who understands arrays too? What is more common,
> POSIX or any other shell?
>
In my experience, Bash is the most common, followed by ash (well
technically busybox in the cases I use). Of course my experience is
coloured by my history. Of the machines that I use and deploy this
holds true. Just have a look at the computers you use. A pattern will
emerge :)
On Debian Lenny+ and Ubuntu 6.10+ you can count on dash as well (as a
sym link from /bin/sh
<snip>
>>
>> It is a seriously handy guide. I had it printed at a printshop here and
>> bound with a coil so that it lays flat on a desk. I don't refer to it as
>> much as before, but it is still very handy to have around.
>>
>
> A good idea ;). Dunno the actual prices for this in the Ruhrgebiet.
>
It cost me ~$80 CDN a couple of years ago. A bit pricey but in the end
I got every penny and more out of it.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFK1FmtwRXgH3rKGfMRAth9AKCJkBoPWeJiYktFutu70seUfA8alQCgkXa9
b1T+eUfMho7XBZxCMDKu50s=
=zu6d
-----END PGP SIGNATURE-----
_______________________________________________
64studio-users mailing list
[email protected]
http://lists.64studio.com/mailman/listinfo/64studio-users