[Toybox] Bash Compatibility Patch
Eric Molitor
eric at improbable.io
Sat Jun 29 15:33:24 PDT 2019
On Sat, 29 Jun 2019 at 18:37, Rob Landley <rob at landley.net> wrote:
> On 6/29/19 7:52 AM, Eric Molitor wrote:
> > I know that you are working on toysh which I'm looking forward to. In the
> > meantime below is a patch to improve compatibility with older/odd
> versions of
> > bash. This fixed a minor build issue I was having on MacOS (which was
> using zsh
> > in emulated bash mode) as well as an oddball embedded SDK using a non-gnu
> > version of bash. I believe these changes are minimal and should be safe
> to
> > apply, if not I wanted to at least get them on the mailing list in case
> others
> > ran into these issues.
>
> I applied this, on the theory you have a testing environment I don't and I
> didn't cause me obvious regressions when I tried it, but I'm not happy
> with it.
>
> > -if [ generated/mkflags -ot scripts/mkflags.c ]
> > +if [ ! -f generated/mkflags ] || [ generated/mkflags -ot
> scripts/mkflags.c ]
>
> 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.
> > 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.
- Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20190629/fa1dc67f/attachment.htm>
More information about the Toybox
mailing list