[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature Request - prepend to file
From: |
Jim Meyering |
Subject: |
Re: Feature Request - prepend to file |
Date: |
Sun, 06 Apr 2008 11:36:38 +0200 |
Brian Dessent <address@hidden> wrote:
> Eric Blake wrote:
>
>> machines. Finally, what syntax did you have in mind? It is probably
>> possible to write a shell script that has that exact same syntax, but uses
>> existing commands, to achieve the task without needing to add a new coreutil.
>
> I agree that for light duty a few simple shell commands are probably
> best. However, there is something to be said for writing a complete
> solution once and then reusing it, rather than reinventing something
> every time it comes up. I'm thinking specifically about all the random
> trivialities and corner cases:
>
> - securely choosing a unique filename for the temporary file
> - preventing a possible race when replacing the original
> - coping with running out of space or being interrupted
> - ensuring that temporary files are always cleaned up
>
> I think these are all examples of things that traditionally the
> coreutils have had to worry about above and beyond the basic
> functionality of a command, so it's not totally unreasonable to make
> such a request. The portability argument of course still holds, and if
> that's a concern it's much better to do it with the shell fragment --
> but for some people portability is not an issue.
>
> In addition, there's the possibility of doing this in-place if there's
> not enough free space and/or if the size of the header fits into memory,
> however that is dangerous since you suffer data loss if interrupted.
You make a good case.
As usual, for suggestions like this, I encourage people to implement
the tool first as a Perl, Python or Ruby script -- and do it robustly.
This is where it'd be good to be able to point people to the
(languishing?) misc-utils project for examples of similar tools. Then,
if/once everyone agrees that the tool is useful enough and has the right
functionality and options, it'd be time to rewrite it in C for coreutils.