[Toybox] Fwd: Re: [patch] add sed
Dave
toybox at overbearing.org
Sun Aug 4 03:27:02 PDT 2013
On 8/4/2013 11:53 AM, Felix Janda wrote:
> Dave wrote:
>> On 8/3/2013 7:25 PM, Strake wrote:
>>>> Besides that there's -i, which could be done easily by open()ing a
>>>> temporary file, writing to that, then renaming to the original filename.
>>> This violates the doctrine to do one thing well. Alas, users want it,
>>> and scripts use it.
>>>
>>> Giving flags to users is like giving cigarettes to children.
>> Frequently on a space constrained device you are forced to edit large
>> files with ed because there is not enough temp space to create that temp
>> file. Frequently in a recovery situation there is zero temp space. If
>> you wanted to implement the -i so it /really really /edits files *i*n
>> place, that would be a good reason to eliminate ed.
> So where keeps ed its buffer?
>
>
> If the edited file fits into memory, instead of open()ing a temporary
> file, writing and renaming one could read the file into memory and
> then use fmemopen().
>
> Felix
I don't know how ed is implemented today, but it used to be the case
that you could edit files that where larger than the available memory of
the device. I remember doing this in a recovery situation where swap
and temp where not available.
-Dave
1375612022.0
More information about the Toybox
mailing list