[Toybox] Bash Compatibility Patch

enh enh at google.com
Mon Jul 1 13:03:32 PDT 2019


On Sat, Jun 29, 2019 at 10:37 AM 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 think they're explicitly saying they're *not* using bash. in one
case they have zsh pretending to be bash [obviously not very well],
and in the other case they talk about a "non-GNU bash", which isn't a
thing, so they must mean some other non-bash shell.)

> >  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?

i suspect this is zsh again. iirc zsh's `which` causes trouble in the
AOSP shell scripts.

> Rob
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net



More information about the Toybox mailing list