[Toybox] macOS sed
Martin Kühl
martin.kuehl at gmail.com
Thu Nov 29 23:53:48 PST 2018
On Fri, 30 Nov 2018 at 00:37, enh via Toybox <toybox at lists.landley.net> wrote:
>
> 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...)
It does not.
However it _does_ say:
> Editing commands other than {...}, a, b, c, i, r, t, w, :, and # can be followed by a <semicolon>, optional <blank> characters, and another editing command.
(http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html#tag_20_116_13_03)
which means standalone labels like `-e ':notset'` are fine
(https://github.com/landley/toybox/blob/6a6b12317149b41b163513e345f43167778f113f/scripts/make.sh#L147)
but embedded labels like `…:clear;…` are not and break
(https://github.com/landley/toybox/blob/6a6b12317149b41b163513e345f43167778f113f/scripts/make.sh#L197)
Breaking them up into separate -e scripts should let them work on macOS.
- Martin
More information about the Toybox
mailing list