[Toybox] sed -e '$a\'

Andy Chu andychup at gmail.com
Wed Mar 23 11:30:38 PDT 2016


> No idea whether that is a valid complaint. coreutils accepts it and
> treats it as "add a newline (but only if needed) and then do nothing".
>
> Debian's update-ca-certificates script uses that to conditionally add a
> newline after a file which may or may not end with a newline:
> http://anonscm.debian.org/cgit/collab-maint/ca-certificates.git/tree/sbin/update-ca-certificates#n100
>
>   # Add trailing newline to certificate, if it is missing (#635570)
>   sed -e '$a\' "$CERT" >> "$TEMPBUNDLE"

Not that this matters, but

1) Why wouldn't they just add a newline unconditionally?  Generally
textual formats don't care how many blank lines you have.

2) It does indeed seem undocumented -- I can't find any mention of
this (unintuitive) behavior in the GNU sed manual or FAQ:

https://www.gnu.org/software/sed/manual/sed.html

Andy

 1458757838.0


More information about the Toybox mailing list