[patch] testsuite/testing.sh: removes obvious bashisms
Cristian Ionescu-Idbohrn
cristian.ionescu-idbohrn at axis.com
Fri May 2 11:52:25 UTC 2008
On Fri, 2 May 2008, Denys Vlasenko wrote:
> On Friday 02 May 2008 12:13, Cristian Ionescu-Idbohrn wrote:
> > > Either declare than we absolutely require echo -ne to work.
> >
> > Easy. Force the shebang lines to (in all scripts):
> >
> > #!/bin/bash
>
> Is it a bashism?
But of course it is. The "good" thing would be we could then stop
worrying about them :)
> It's more like echo-ism...
Really, what I wanted to underline is this:
If we want those test scripts to all work with various default
shells, than a good approach is to try to make them posix-complient.
The two major examples I gave are 'echo' and 'printf'.
echo usage in the test-scripts:
- the '-e' options is _not_ posix
- use of the '-e' option may lead to several tests failing if the
default shell (dash on several distributions) does not support it
- I think the '-n' option should also be avoided
- I'm _not_ saying busybox echo should not support the '-e' and '-n'
options
- and this is what I base my statements on:
http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html
- the above document talks about "XSI-conformant systems" and says
"The following character sequences shall be recognized on
XSI-conformant systems"; '\xHH' is not one of them, but '\OOO' is; the
question is: can we always assume XSI-conformancy of all default
shells on all distributions?
printf usage in the test-scripts:
- printf should replace 'echo -ne', as according to this:
http://www.opengroup.org/onlinepubs/009695399/utilities/printf.html
it that's what it is intended for (among othe things)
- escape sequences like '\xHH' are posix-complient, but '\OOO' are and
should be used instead
> > I have no problems with that, but I still think printf is easier and
> > more flexible.
Should have added "as a replacement for 'echo -ne'".
> printf has more than just aestethic problems.
Obviously you don't like printf :)
> All "new-style" tests use echo -ne (indirectly). If you change that to
> printf, you nned to audit them all for "%<letter>" format specifier.
Hmm... Yes, some things might break in such cases, but it looks like
'echo -ne' leads to far more breakage on some distributions.
Cheers,
--
Cristian
More information about the busybox
mailing list