From 81b7585ad19e1ee0a1a43dda44dd21f11bfd6e86 Mon Sep 17 00:00:00 2001 From: Pádraig Brady
Date: Wed, 26 May 2010 09:27:53 +0100 Subject: 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 --- tests/misc/truncate-parameters | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tests') 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 -- cgit v1.2.3-70-g09d2