[Toybox] sed -e '$a\'

Andy Chu andychup at gmail.com
Wed Mar 23 17:40:17 PDT 2016


>> 2) It does indeed seem undocumented -- I can't find any mention of
>> this (unintuitive) behavior in the GNU sed manual or FAQ:
>
> The _fun_ part is that this is doubly nonstandard, because the logic
> I've used so far is if the line of input didn't have a newline, we
> don't add one _until_ we output another line after it, in which case
> we backfill the missing newline.

I don't know enough about sed to say anything useful about this part
... I pretty much just stick to s// .

Though I am wondering about the general toybox philosophy of
compatibility.  I think some compatibility is essential, but extreme
compatibility is often at odds with the goal of simple code.  I would
define extreme compatibility as "bug for bug" compatibility.

I've looked through most of the docs, which generally are very lucid
about the project goals, but didn't see anything explicitly about
compatibility.  (e.g. http://landley.net/toybox/design.html)

I know it's basically a mixture of POSIX, other standards, common
practice like GNU coreutils, and Aboriginal Linux use cases.  I see
that Aboriginal has a sources/patches directory, so I wonder where you
draw the line at where to patch vs. where to re-implement bugs.

I noticed the other recent example of making a change for the Perl build.

Given what I know, I would classify implementing 'c\' and 'a\' as
bug-for-bug compatibility -- that seems like truly an accidental
implementation quirk rather than a useful extension or generalization
of existing behavior.  There are some things you can guess the
semantics of, even if they're not documented of, but this doesn't seem
like one of those things.

FWIW there are some other sed implementations listed here, mainly on
commercial Unixes:

http://sed.sourceforge.net/sedfaq7.html

Andy

 1458780017.0


More information about the Toybox mailing list