[Toybox] macOS sed

enh enh at google.com
Thu Nov 29 15:37:30 PST 2018


On Wed, Nov 28, 2018 at 3:04 PM Rob Landley <rob at landley.net> wrote:
>
> On 11/28/18 3:42 PM, enh via Toybox wrote:
> > according to https://stackoverflow.com/questions/12272065/sed-undefined-label-on-macos
> > macOS' sed only lets you branch backwards. this breaks mkflagsh and
> > getglobals in scripts/make.sh.
> >
> > i'm assuming the answer is "you'll need `brew install gnu-sed` to
> > bootstrap, and can use a toybox sed from then on", but should we give
> > a clearer error? something like "if you're on macOS but i can't find
> > gsed, suggest `brew install`"?
>
> Aha. That's why it had $SED.
>
> Wait, where in posix says you can only branch _backwards_? :label is a label you
> can jump to, it doesn't say it has to have already encountered it in the script.
> (Did I miss a curve in the reading again? I thought I'd read that one REALLY
> CLOSELY, although once again time has managed to go by since then...)
>
> Anyway, I'm happy to give a clearer error. _How_? (What does "uname -o" say on a
> mac?)

"illegal option" :-)

just plain `uname` gets me "Darwin".

(given that `toybox uname -o` behaves differently than coreutils and
busybox ["Linux" versus "GNU/Linux"], and isn't even documented in
toybox, you might want to steer clear of that anyway.)

> At the very leas I can make $SED default to "gsed" when [[ "$(uname -o")
> =~ Mac ]]  or some such, then at least the error is gsed missing. But that
> assumes I'm detecting MacOS...

the reason why i haven't sent you a patch is that there's a bunch of
other scripts that need similar treatment... should i factor it out
into scripts/findsed.sh and source that from the affected scripts?

> Rob
>
> P.S. My commit to add an extra symlink dereferencing layer so you can alias
> command names, this is one of the things I had vaguely in mind. So toybox can
> provide _gsed_ for scripts that care. Toybox's build can't be the _only_ one on
> macosx...



More information about the Toybox mailing list