Subject: Re: bug#24007: Report cat bugs to [email-masked]

From: Eric Blake <[email-masked]>
Date: Sat, 16 Jul 2016 10:39:48 -0600

tag 24007 notabug
thanks

On 07/16/2016 12:11 AM, NAVEEN KUMAR wrote:
> Hi Team,
> 
> Greetings!
> 
> I was sitting next my system looking for some basic code brush up and was
> playing with CAT command, and though of some kind of additional features to
> our existing CAT command, such as...
> 
> 
> 
> *"Write a CAT command program, which will allow appending text or lines of
> code at user specified line" not only at the end of file.*
> 
> *Ex: cat >> filename.c line_number *

That won't work.  The >> operator in the shell opens a file in
append-only mode, and the operating system enforces that in append mode,
data can only be added at the end, not the middle.

Furthermore, what you suggested can already be done with sed, so there
is no real reason to bloat cat to add non-standard functionality that
can already be done with a standard tool.

sed "$line r $file_to_insert" $file_to_expand

inserts the contents of $file_to_insert starting at line $line of the
file $file_to_expand, and pipes the resulting concatenation to stdout.

These days, it's a very high bar to justify adding new features, and we
prefer to save additions for things that either match other
implementations or that accomplish things more efficiently than what is
possible using only standard tools.  Therefore, I'm closing this feature
suggestion in the bug database as it is unlikely to be implemented, but
do feel free to add further comments on the thread.

Feature suggestions can be sent to [email-masked], rather than the
bug list, if you are not sure whether it is worth pursuing, so that we
don't clog up the bug database.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org