[patch] testsuite/testing.sh: removes obvious bashisms
Denys Vlasenko
vda.linux at googlemail.com
Fri May 2 06:19:02 PDT 2008
On Friday 02 May 2008 13:52, Cristian Ionescu-Idbohrn wrote:
> 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.
I agree.
> 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?
I understand this and agree that making it work on more systems
is a good goal.
>
> 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 :)
I don't have any problems with it. I just know that new-style scripts
can break if we switch to it, because their strings can contain "%".
Therefore it cannot be used.
> > 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.
Therefore neither echo -ne nor printf is ok.
I propose using helper binary.
--
vda
More information about the busybox
mailing list