bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: merge sort temporary files


From: Charlie Gordon
Subject: Re: merge sort temporary files
Date: Fri, 14 May 2004 13:40:49 +0200

"Paul Eggert" <address@hidden> wrote in message
news:address@hidden
> Instead of adding a new option, I think I'd rather change 'sort' to
> cater to your (relatively common) case, rather than to the (relatively
> contrived) cases like `cat F | sort -m -o F - G' where people should
> know that they're getting into trouble anyway.

I completely agree that this example is quite contrived, and your patch is
welcome.
Yet there is a simple way to fix sort's behaviour to cater to this case
without resorting (no pun intended) to a temporary file.  sort should first
try to unlink the output file before opening it in "w" mode.
cat would keep reading the old file while sort writes to a new file with the
same name.
reasons why this would fail are :
- bogus file system (windows) -> current behaviour
- output file is a symlink -> the user will get in trouble with this sooner
or later -> check for this and do not unlink that.
- inode number for output file will change. is this a problem ?

Is there a major reason I'm missing that makes this kind of change
undesirable ?

Chqrle.









reply via email to

[Prev in Thread] Current Thread [Next in Thread]