Hi,

I've found the following strange result while testing.

Running the command

    busybox sh -x -c 'test="[ \t\r]";[ ${#test} -gt 0 ] && \
( [ "${test#[}" = "$test" ] || [ "${test%]}" = "$test" ] ) && \
echo true || echo false'

produces the unexpected output

    + test=[ \t\r]
    + [ 7 -gt 0 ]
    + [ [ \t\r] = [ \t\r] ]
    + echo true
    true

- the first square bracket wasn't removed by "${test#[}", the
following comparison finds no difference and the whole (inner) term
evaluates to "true". The "remove suffix pattern" shows the same effect.

This busybox version has been built with uClibc-0.9.33.2 for MIPS
(34kc). Two different builds show the same behavior, one version came
from a router vendor (AVM) in Germany and the other was made by myself.

    AVM => BusyBox v1.22.1 (2016-11-01 19:55:42 CET) multi-call binary.
    own => BusyBox v1.24.2 (2016-09-24 17:17:47 CEST) multi-call binary.

Running the same command on x86 with a glibc-based BusyBox leads to the
expected result:

    + test=[ \t\r]
    + [ 7 -gt 0 ]
    + [  \t\r] = [ \t\r] ]
    + [ [ \t\r = [ \t\r] ]
    + echo false
    false

I haven't looked into the sources yet, probably it's a misbehavior of
the underlying C library?

Have I overlooked something important here?

If it's really a problem (one case has to be wrong in my opinion *g*)
and the proposal to fix it, is expected beside this pure notification, I
would try to track down the issue.
-- 
Best regards / mfG

.PeH

[email protected]

Attachment: 0x30311D96.asc
Description: application/pgp-keys

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to