Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] binary search of binary data



On Wed, Dec 29, 2004 at 07:52:48AM -0800, Dave Brown wrote:
> I just verified it with my bash-3.00 and it does, indeed,
> truncate.  I just sent in a bug report to the bash folks about
> this--I think that's incorrect behaviour.

To which I got this reply:

    dagbrown@example.com wrote:
    > Description:
    >     $'(string1)\x00(string2)' truncates the string at \x00.

    The execve() interface underlying the invocation of all external
    commands uses \x00 to indicate the end of a string.  There's no way
    around it for external commands.  bash could handle builtins
    differently, but that inconsistency could lead to trouble.  Consider:
    var=...
    out=`/bin/echo "$var"`
    test "$var" = "$out"
    You would expect this test to always exit 0, but if var could contain
    null characters, and if the internal test command could see those,
    then the test would fail.

I guess the bash guys want bash builtins to mimic all of the
arbitrary limitations of external commands, despite not being
bound by such limitations.  Interesting way of looking at things.

(I wonder if bash's builtins should also mimic execve()'s
argument-length limit in order to conceal the fact that builtins
are actually builtins, not external commands.)

--Dave


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links