Bug#832088: sed: silently fails with -n option specified first
Hello, Paolo Bonzini wrote: On 22/07/2016 09:02, Daniel Iancu wrote: sed -ni 's/foo/bar/' test # fails So this is not a bug. I've expanded sed's manual to mention this specific issue: https://git.savannah.gnu.org/cgit/sed.git/commit/?id=a36e8abccc5db38e4d2f8ea2bbb3e78dfddacd78 regards, - assaf
Bug#832088: sed: silently fails with -n option specified first
On 22/07/2016 09:02, Daniel Iancu wrote: > Package: sed > Version: 4.2.2-4+b1 > Severity: normal > > Sed silently fails when -n option is specified first and leaves > the file blank. Thus resulting in the loss of the file contents. > Example: > # cd /tmp > echo 'foo' > test > sed -ni 's/foo/bar/' test # fails > > echo 'foo' > test > sed -in 's/foo/bar/' test # works "-n" says "do not print anything by default", so sed is working as expected---not printing anything since you don't have a "w" command. "-in" says "do in-place editing and leave a backup in a file whose name is the input file name followed by 'n'". In this case sed adds a default print action at the end of the loop. So this is not a bug. Paolo
Bug#832088: sed: silently fails with -n option specified first
Package: sed Version: 4.2.2-4+b1 Severity: normal Sed silently fails when -n option is specified first and leaves the file blank. Thus resulting in the loss of the file contents. Example: # cd /tmp echo 'foo' > test sed -ni 's/foo/bar/' test # fails echo 'foo' > test sed -in 's/foo/bar/' test # works