[Toybox] Bash Compatibility Patch

Rob Landley rob at landley.net
Sat Jun 29 19:58:46 PDT 2019


On 6/29/19 5:33 PM, Eric Molitor wrote:
>     In which bash version does comparing a file that doesn't exist return true?
> 
> I believe this is a bug in the zsh version of bash emulation. I originally ran
> into this on MacOS but also reproduced with zsh 5.7 running in emulated bash
> mode on Linux. I was not able to reproduce it with modern versions of bash or mksh.

The reason I'm reluctant to apply this kind of patch (although I did in this
case) is I'm _going_ to break that environment again next time I change
something. Either I'm afraid to make changes, or the environment full of random
bugs I can't regression test bit-rots quickly.

>     >  if [ -z "$SED" ]
>     >  then
>     > -  [ ! -z "$(which gsed 2>/dev/null)" ] && SED=gsed || SED=sed
>     > +  [ ! -z "$(command -v gsed 2>/dev/null)" ] && SED=gsed || SED=sed
>     >  fi
> 
>     Toybox provides a which this works with. What problem did you hit?
>  
> On an old arm11 sdk this was evaluating to true even though gsed was not
> present. I had originally worked around this by specifying SED=sed when building
> until I realised that command -v worked reliably.

SED=sed is probably the better workaround. This is a clear host bug.

*shrug* Applied anyway. I need to work out how to get toybox to build with more
of toybox, which is always a chicken and egg problem...

Rob



More information about the Toybox mailing list