diff options
-rw-r--r-- | src/truncate.c | 6 | ||||
-rwxr-xr-x | tests/misc/truncate-parameters | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/truncate.c b/src/truncate.c index fd321c6c5..3bc52ca14 100644 --- a/src/truncate.c +++ b/src/truncate.c @@ -286,6 +286,9 @@ main (int argc, char **argv) break; case 's': + /* skip any whitespace */ + while (isspace (*optarg)) + optarg++; switch (*optarg) { case '<': @@ -305,6 +308,9 @@ main (int argc, char **argv) optarg++; break; } + /* skip any whitespace */ + while (isspace (*optarg)) + optarg++; if (*optarg == '+' || *optarg == '-') { if (rel_mode) diff --git a/tests/misc/truncate-parameters b/tests/misc/truncate-parameters index e41683190..27a22a91f 100755 --- a/tests/misc/truncate-parameters +++ b/tests/misc/truncate-parameters @@ -40,4 +40,10 @@ truncate --io-blocks --reference=file file && fail=1 # must specify valid numbers truncate --size="invalid" file && fail=1 +# spaces not significant around size +truncate --size="> -1" file && fail=1 +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 + (exit $fail); exit $fail |