[patch] testsuite/testing.sh: removes obvious bashisms

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Thu May 1 09:11:06 PDT 2008


I'm not sure I found all of them.  Didn't test function 'mkchroot', but I
can't see how my modifications would make it fail.

I tested using bash, dash and ash as shells.

You will notice this:

 testing()
 {
+  local ECHO='echo -e'
+
+  [ -z "$($ECHO)" ] || ECHO='echo'
+

'-e' is non-posix and dash has that builtin.  That is, if the standard
shell is dash (ubuntu and derivatives, and RSN debian):

  # echo -e

will output:

  -e

and the tests will go wrong and all that...

Maybe some 'echo' replacement like:

	ECHO='echo -e'
	[ -z "$($ECHO)" ] || ECHO='echo'

in testsuite/runtest (and then propagated to all scripts in and below the
testsuite directory) sould be a better way to do it.  Thoughts?

'echo -n' may also cause problems.

I read here:

  http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html

,----
| A string to be written to standard output. If the first operand is -n, or
| if any of the operands contain a backslash ( '\' ) character, the results
| are implementation-defined.
|
| [XSI] [Option Start] On XSI-conformant systems, if the first operand is
| -n, it shall be treated as a string, not an option.
`----

'printf' instead of 'echo -e[n]' may be a safer way do do it, but...

I noticed that even if I replaced 'echo -e[n]' with printf, I still
run into problems :(  For example testsuite/bunzip2.tests:

	echo -ne "\x02\x00\x6e\xd7\xac\xfd\x06\x00\x00\x00"

No joy just replacing 'echo -ne' with 'printf', as dash builtin 'printf'
does not support:

  \xHH    byte with hexadecimal value HH (1 to 2 digits)

as printf (GNU coreutils) 6.10.  bash builtin printf (and even echo), on
the other hand, seems to support that and more.  But posix-printf should
support octal sequences, so this:

	printf "\002\000\156\327\254\375\006\000\000\000"

will work better (see 2nd attachment).


Cheers,

-- 
Cristian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testing.sh.patch
Type: text/x-diff
Size: 1330 bytes
Desc: 
Url : http://busybox.net/lists/busybox/attachments/20080501/ee745138/attachment-0002.patch 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bunzip2.tests.patch
Type: text/x-diff
Size: 1458 bytes
Desc: 
Url : http://busybox.net/lists/busybox/attachments/20080501/ee745138/attachment-0003.patch 


More information about the busybox mailing list