bug#6268: Suggestion: truncate should allow -r and -s options together (original) (raw)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
From: | Jim Meyering |
---|---|
Subject: | bug#6268: Suggestion: truncate should allow -r and -s options together |
Date: | Fri, 28 May 2010 09:59:39 +0200 |
Pádraig Brady wrote:
Subject: [PATCH] truncate: support sizes relative to an existing file
* doc/coreutils.texi (truncate invocation): Mention that --reference bases the --size rather than just setting it. * src/truncate.c (usage): Likewise. Also remove the clause describing --size and --reference as being mutually exclusive. (dotruncate): Add an extra parameter to hold the size of a referenced file, and use it if positive. (main): Pass the size of a referenced file to dotruncate(). * tests/misc/truncate-parameters: Adjust for the new combinations. * NEWS: Mention the change Suggested by Richard W.M. Jones
Nice. Thanks!
Not new with this change, but what about --ref=non-regular-file ?
Perhaps truncate should refuse to use st_size info from a non-regular file.
Here's a pathological example:
$ echo abcdefgh > bar $ strace -e ftruncate ./truncate --ref=/dev/tty bar ftruncate(3, 0) = 0 $ wc -c bar 0 bar
It's obvious that such an example is not likely in practice, but since currently truncate's --ref uses stat, it would follow a symlink, too.
For a directory you'd get unportable and probably surprising results. Using such a reference size deserves at least a warning.
- bug#6268: Suggestion: truncate should allow -r and -s options together, Richard W.M. Jones, 2010/05/25
- bug#6268: Suggestion: truncate should allow -r and -s options together, Pádraig Brady, 2010/05/25
* bug#6268: Suggestion: truncate should allow -r and -s options together, Pádraig Brady, 2010/05/26
* bug#6268: Suggestion: truncate should allow -r and -s options together, Richard W.M. Jones, 2010/05/26
* bug#6268: Suggestion: truncate should allow -r and -s options together,Jim Meyering <=
* bug#6268: Suggestion: truncate should allow -r and -s options together, Pádraig Brady, 2010/05/28
* bug#6268: Suggestion: truncate should allow -r and -s options together, Pádraig Brady, 2010/05/28
* bug#6268: Suggestion: truncate should allow -r and -s options together, Jim Meyering, 2010/05/29
* bug#6268: Suggestion: truncate should allow -r and -s options together, Pádraig Brady, 2010/05/29
* bug#6268: Suggestion: truncate should allow -r and -s options together, Voelker, Bernhard, 2010/05/31
* bug#6268: Suggestion: truncate should allow -r and -s options together, Pádraig Brady, 2010/05/31
* bug#6268: Suggestion: truncate should allow -r and -s options together, Richard W.M. Jones, 2010/05/26
- bug#6268: Suggestion: truncate should allow -r and -s options together, Pádraig Brady, 2010/05/25
- Prev by Date:bug#6281: Fwd: Possible bug in coreutils-8.5 or associated gnulib version
- Next by Date:bug#6281: Fwd: Possible bug in coreutils-8.5 or associated gnulib version
- Previous by thread:bug#6268: Suggestion: truncate should allow -r and -s options together
- Next by thread:bug#6268: Suggestion: truncate should allow -r and -s options together
- Index(es):