site  contact  subhomenews

Ash, Bash, Dash

January 31, 2009 — BarryK
Regarding the move to Dash by some distros, we need to ask just what is Dash? Well, it is basically Ash, and we have always had Ash in Puppy! See this URL:

http://www.in-ulm.de/~mascheck/various/ash/

The Ash shell is provided by Busybox. In a script, you put this at the top:
#!/bin/ash

With Busybox, if you link /bin/sh to the busybox executable (it is normally linked to bash), then this will also run Ash (depending on how Busybox is configured):
#!/bin/sh

Now this is very interesting. Running Puppy 4.1.2 on my laptop, locale en_AU, my speed-test script gives 33 seconds. Change over to Ash and I get 26 seconds.

However it gets more exciting.... if I first run 'export LANG=C' then using Bash the script takes 22 seconds, using Ash takes just 17 seconds!

Very old versions of Puppy did not have Bash, just Busybox Ash. I don't recall what version that Bash got introduced, but I think it was back in the Puppy1 series. The reason was improved compatibility with all the scripts out there, but oh boy I never realised right until now, what a speed penalty we have paid!

Then I wondered about Busybox in the initial ramdisk in Puppy, where we use Ash to run the 'init' script. I configured Busybox with this:
# CONFIG_LOCALE_SUPPORT is not set

On the other hand, Busybox in the main Puppy filesystem is configured with:
CONFIG_LOCALE_SUPPORT=y

I tested with the static busybox from the initial ramdisk, and was surprised that I got 26 seconds, then when set LANG=C I got 17 seconds. Huh, locale is supposed to be disabled! This is weird.

Final thought:

Comments

Ash Bash Dash
Username: Béèm
Nice to know there is a 32 of january. Special for Australia? ;-)

32=1
Username: 01micko
"Beem, yes, different whatzisphere you know. Barry, POSIX compliance is what 'amigo' pointed me to, which dash is, and moreso ash than bash, lucky there's no hash.

dash vs. ash
Username: Dougal
"No, dash is not exactly the same as Busybox ash. dash is really just the bare minimum, while Busybox ash includes some bashisms (the "let" command is one I'm aware of) and I suspect dash might be faster, as the Debian folk are probably interested in it (busybox is optimized for size). Note that just move to using dash, in case any of your scripts include bashisms... I've been planning to do so for a while and have already changed a few of my scripts to explicitly state "/bin/bash" if they do (rc.network is one of them). You can always get rid of bashisms, but I'm not sure the extra subshells etc. that it will require won't actually lose any speed improvements...

ash
Username: linuxcbon
"Can you put [code]#!/bin/ash export LANG="C"[/code] In many scripts ?


Tags: puppy