diff options
author | Pádraig Brady <P@draigBrady.com> | 2010-05-26 09:27:53 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2010-05-28 14:23:04 +0100 |
commit | 81b7585ad19e1ee0a1a43dda44dd21f11bfd6e86 (patch) | |
tree | 9e30d8ce0e19443360810254fe9f22b9a8faec14 /tests/misc/truncate-parameters | |
parent | d4201905ab4ed20ec3a5e2aea528835552e84a1d (diff) | |
download | coreutils-81b7585ad19e1ee0a1a43dda44dd21f11bfd6e86.tar.xz |
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.
(do_truncate): 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 do_truncate().
* tests/misc/truncate-parameters: Adjust for the new combinations.
* NEWS: Mention the change
Suggested by Richard W.M. Jones
Diffstat (limited to 'tests/misc/truncate-parameters')
-rwxr-xr-x | tests/misc/truncate-parameters | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/misc/truncate-parameters b/tests/misc/truncate-parameters index 65240702a..c2f701970 100755 --- a/tests/misc/truncate-parameters +++ b/tests/misc/truncate-parameters @@ -30,7 +30,7 @@ truncate --size=0 && fail=1 # must specify size. don't default to 0 truncate file && fail=1 -# mixture of size & reference not allowed +# mixture of absolute size & reference not allowed truncate --size=0 --reference=file file && fail=1 # blocks without size is not valid @@ -45,4 +45,14 @@ truncate --size=" >1" file || fail=1 #file now 1 truncate --size=" +1" file || fail=1 #file now 2 test $(stat --format %s file) = 2 || fail=1 +# reference allowed with relative size +truncate --size=" +1" -r file file || fail=1 #file now 3 +test $(stat --format %s file) = 3 || fail=1 + +# reference allowed alone also +truncate -r file file || fail=1 #file still 3 +test $(stat --format %s file) = 3 || fail=1 +truncate -r file file2 || fail=1 #file2 now 3 +test $(stat --format %s file2) = 3 || fail=1 + Exit $fail |