On 2015-05-09 10:45, Sébastien Marie wrote: > > Here a small patch to sed to make 'i' and 'a' command to always > > append "\n" after 'text'. > > After realizing that even if the patch is simple, it could break a > lot of thing (changing the behaviour of 'i' and 'a' command will > necessary break some sed scripts),
Correct. If the a/i command comes from a script, it works as expected: $ cat x.sed i\ x a\ z tim@openbsd $ echo y | sed -f x.sed | hexdump -c 0000000 x \n y \n z \n 0000006 which even works on improperly-formed text files: $ dd if=x.sed of=y.sed bs=9 count=1 $ cat x.sed # note no final newline i\ x a\ ztim@openbsd $ echo y | sed -f y.sed | hexdump -c 0000000 x \n y \n z \n 0000006 $ # yet a newline gets properly appended The issue only happens when the a/i comes from command-line arguments: $ echo y | sed -e 'i\ x' -e 'a\ z' | hexdump -c 0000000 x y \n z 0000004 which seems like it should precipitate a test (and newline addition) at the argument-parsing stage rather than the a/i processing stage. The list of .sed files you provided should all be invoked with "sed -f <filename>" so they would all bypass the crazy command-line edge-case in question. -tkc
