busybox sed, 'r' command

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Wed Mar 23 14:12:50 UTC 2016


On Wed, 23 Mar 2016, Ron Yorston wrote:
>
> Since the 'r' command requires a space before the filename it will need
> to be quoted.  Some of your examples have quotes and some don't so you
> aren't always comparing the same thing.

Right.  Still.  The different behaviour confused me.

> "sed r -" is an 'r' command with no filename while the "sed 'r -'" is an
> 'r' command with a filename of '-'.  It appears that GNU sed and BusyBox
> sed handle an 'r' command with no filename differently.

Yes.  That seems to be it.  Question is if busybox sed should mimic
GNU sed behaviour or not.  The current GNU sed behaviour might be seen
upon as a bug.  But it's been like that for ages.  Maybe it's a bug
upstream wants to keep for historical reasons?

> Also note that printf doesn't issue a newline at the end of the string.
> This can affect the results.

Yes, that was intentional.  A file that lacks a <newline> at the end
of the last line, passing through:

	$ sed r <filename>

enforces proper line termination on last line.  I know there's other
cludge that can achieve the same thing.


Cheers,

-- 
Cristian


More information about the busybox mailing list