diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2004-07-30 23:24:03 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2004-07-30 23:24:03 +0000 |
commit | 94732c8a71d606796ea656593eb085fa0f43a04f (patch) | |
tree | 6f14c34740629fa7235047cbef62883087800cac | |
parent | 55710cf6e198f14539f140310b6b232f14d88180 (diff) | |
download | coreutils-94732c8a71d606796ea656593eb085fa0f43a04f.tar.xz |
Improve comment for first_same_file.
-rw-r--r-- | src/sort.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/sort.c b/src/sort.c index 7ac809049..8c92b0855 100644 --- a/src/sort.c +++ b/src/sort.c @@ -1881,7 +1881,17 @@ sortlines_temp (struct line *lines, size_t nlines, struct line *temp) } /* Return the index of the first of NFILES FILES that is the same file - as OUTFILE. If none can be the same, return NFILES. */ + as OUTFILE. If none can be the same, return NFILES. + + This test ensures that an otherwise-erroneous use like + "sort -m -o FILE ... FILE ..." copies FILE before writing to it. + It's not clear that POSIX requires this nicety. + Detect common error cases, but don't try to catch obscure cases like + "cat ... FILE ... | sort -m -o FILE" + where traditional "sort" doesn't copy the input and where + people should know that they're getting into trouble anyway. + Catching these obscure cases would slow down performance in + common cases. */ static int first_same_file (char * const *files, int nfiles, char const *outfile) |