[Toybox] is orthodoxy a strong value of toybox?
Marc Chantreux
mc at unistra.fr
Tue Sep 6 12:18:14 PDT 2022
hello Rob,
First, thank you so much for such a long, interesting and detailed answer
> > which dash mksh oksh yash zsh bash|xargs realpath|xargs ls -s|sort -nr
> > 1208 /bin/bash
> > 864 /bin/zsh
> > 400 /usr/bin/yash
> > 288 /bin/mksh
> > 284 /bin/oksh
> > 124 /bin/dash
> That kinda needs context. A dynamic i686 build against musl-libc of toysh:
> $ ls -l sh
> -r-xr-xr-x 1 landley landley 80032 Sep 2 06:53 sh
> A static x86-64 musl build of the same code:
> -r-xr-xr-x 1 landley landley 166696 Sep 2 06:54 sh
> Dynamic x86-64 version against glibc:
> -r-xr-xr-x 1 landley landley 94440 Sep 2 06:55 sh
> And of course that's toysh standalone, not the amount of space enabling it in
> menuconfig adds to a toybox defconfig binary.
Those are indeed astonishing differences. All the binaries I tested came from
their debian packaging so I guess they are all compiled against glibc
with the standard architecture.
> Bash was not just the standard shell of Linux for its first 15 years, and was
> literally the first program Linux ever ran in 1991
I really see bash as a bloated korn shell that becames standard on linux
shell just because it came as a part of the GNU project and lot of
people (including myself) used bash because we thought the choice was
made after curration.
But I see a trend to replace bash by
* zsh when the main goal is to provide a confortable shell with a lot of features
(and really: bash can't compete with zsh on it)
* dash when the goal is to provide the minimal setup for simple scripts
and most of the scripts I reviewed don't even use the features from
dash also provides so most of them can be converted to dash
scripts with minor changes (just removing useless bashisms).
Also "The Debian policy manual has long mandated that "shell scripts
specifying '/bin/sh' as interpreter must only use POSIX features" so
dash is just enough." (https://wiki.ubuntu.com/DashAsBinSh)
I added the mksh variants originated from openBSD (mksh, oksh) because
they are very good at providing a good balance between feature and
weight and are saddly underrated in the linux world.
I put yash because I see a recent buzz about it. I don't know it that
much but noticed it is half the size of zsh but yet provide process
expansions so once again another compromise.
> > and I'm just happy
> > this way. plus: it needs compound command to declare a function ;)
> $ bash -c 'x() { echo hello;}; x'
> hello
$ dash -c 'x() echo hello; x'
hello
why should I bet on a 10 times bigger, considered slow shell to do less
than what I want to write?
> Hmmm... https://en.wikipedia.org/wiki/Doxa says it means "common belief or
> popular opinion". Maybe you're not wrong? At the top of
again: I appologize
* orthodoxy wasn't appropriated in an english text
* my belief of the fact that toybox would stick on POSIX was wrong.
> project after the Linux Foundation bureaucracy took control of it, eventually
> leading to https://lwn.net/Articles/658809/
this was a very interesting reading! I didn't know LSB was that much
challenged.
About the rest of your mail: thanks for the context about all your
links. I'll read them carefully.
> file, I'm unhappy. (This leads into a discussion of "build environment" vs
> "development environment", the latter of which should probably have X11 or
> simiilar and the first of which doesn't need it, which is a LONG DIGRESSION and
> does not result in clear lines between one and the other.)
I don't understand way X11 would be necessary in a "development
environment" but assuming awk and make are available from the build env,
I would think about vi, ctags and maybe cscope and a debugger.
> implementations. (Or at least keep that down to a dull roar.) I still don't
> understand why ";" on its own without a statement in front of it is an error,
> leading to:
>
> $ if true; then; echo hello; fi
> bash: syntax error near unexpected token `;'
> $ if true; then
> > echo hello; fi
> hello
>
> I mean, LOGICALLY the ; and the line break should be the same, right? But no.
> You can have a line break in places you can't have a ; and... ok then?
to me those kind of flaws are not important because what you really want
to write is indeed `then echo hello`. there are more things that are
problematic to me. for example:
those are ok
>&2 echo error
echo error >&2
{
echo error
echo error
echo error
} >&2
but this one isn't
>&2 {
echo error
echo error
echo error
}
another think I hate in *sh is that a glob with no match returns the
glob itself and some examples use this as as feature.
yet another? why the hack can't I use read at the end of a pipe the
way bash and zsh does?
this is ok
read h < /etc/hostname
echo $h
this is not
hostname | read h
echo ${h?can't read the output of a pipe}
I really would like a shell to fix all those known problems and with
a syntax inspired by rc and the alternative zsh but I fear there would
be no adoption.
regards.
--
Marc Chantreux
Pôle de Calcul et Services Avancés à la Recherche (CESAR)
http://annuaire.unistra.fr/p/20200
More information about the Toybox
mailing list