Re: busybox sed, 'r' command

2016-03-24 Thread Cristian Ionescu-Idbohrn
On Thu, 24 Mar 2016, Ron Yorston wrote: > > and specifically about 'r': > >If rfile does not exist or cannot be read, it shall be treated as if >it were an empty file, causing no error condition. My observation, looking at the strace from GNU sed, is it attempts to open a file with

Re: *FLAWED* Re: busybox sed, 'r' command

2016-03-24 Thread Ron Yorston
I was curious what POSIX says and how other *nix systems would handle Christian's examples. On the 'r' command POSIX makes a general comment: The r and w command verbs, and the w flag to the s command, take an rfile (or wfile) parameter... and specifically about 'r': If rfile does not

Re: *FLAWED* Re: busybox sed, 'r' command

2016-03-23 Thread Mike Frysinger
busybox generally follows a pretty simple flow: (1) is the behavior you're looking at explicitly documented by POSIX ? if yes, then do what POSIX says & you're done (2) is the behavior described as "implementation defined" by POSIX ? if yes, do whatever produces smaller code (3) is the

Re: *FLAWED* Re: busybox sed, 'r' command

2016-03-23 Thread Cristian Ionescu-Idbohrn
On Wed, 23 Mar 2016, Ralf Friedl wrote: > > On the other hand, I don't know why busybox sed needs exactly one space > between command and filename. GNU sed works with zero or more spaces. Good points, everyone. Thanks. Still... # Note, the input file /tmp/bar lacks the on the last line #

Re: busybox sed, 'r' command

2016-03-23 Thread Michael Conrad
On 3/23/2016 12:12 PM, Ralf Friedl wrote: Cristian Ionescu-Idbohrn wrote: sed (GNU sed) 4.2.2 can do this: $ printf 'foo bar baz' | sed r - foo bar baz or, after storing the text in a file: $ printf 'foo bar baz' >/tmp/bar $ sed r /tmp/bar foo

Re: busybox sed, 'r' command

2016-03-23 Thread Ralf Friedl
Cristian Ionescu-Idbohrn wrote: sed (GNU sed) 4.2.2 can do this: $ printf 'foo bar baz' | sed r - foo bar baz or, after storing the text in a file: $ printf 'foo bar baz' >/tmp/bar $ sed r /tmp/bar foo

Re: busybox sed, 'r' command

2016-03-23 Thread Cristian Ionescu-Idbohrn
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 -"

Re: busybox sed, 'r' command

2016-03-23 Thread Ron Yorston
Cristian, 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. "sed r -" is an 'r' command with no filename while the "sed 'r -'" is an 'r' command with a filename of

busybox sed, 'r' command

2016-03-23 Thread Cristian Ionescu-Idbohrn
sed (GNU sed) 4.2.2 can do this: $ printf 'foo bar baz' | sed r - foo bar baz or, after storing the text in a file: $ printf 'foo bar baz' >/tmp/bar $ sed r /tmp/bar foo bar baz But busybox