* NEWS: dd bs= operands now silently override later ibs= and obs=,
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 22 Dec 2006 09:09:37 +0000 (10:09 +0100)
committerJim Meyering <jim@meyering.net>
Fri, 22 Dec 2006 09:09:37 +0000 (10:09 +0100)
as POSIX requires.
* src/dd.c (scanargs): Implement it.
* tests/dd/misc (outbytes): Test it.
* doc/coreutils.texi (dd invocation): Specify that bs=N
overrides later ibs and obs, undoing part of the
previous change.  (The behavior was wrong.)

ChangeLog
NEWS
doc/coreutils.texi
src/dd.c
tests/dd/misc

index e9c84ce..fa0a39b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
-2006-12-21  Jim Meyering  <jim@meyering.net>
-
-       * Makefile.maint (patch-check): Fix shell quoting.
+2006-12-21  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * NEWS: dd bs= operands now silently override later ibs= and obs=,
+       as POSIX requires.
+       * src/dd.c (scanargs): Implement it.
+       * tests/dd/misc (outbytes): Test it.
+       * doc/coreutils.texi (dd invocation): Specify that bs=N
+       overrides later ibs and obs, undoing part of the
+       previous change.  (The behavior was wrong.)
 
 2006-12-20  Jim Meyering  <jim@meyering.net>
 
diff --git a/NEWS b/NEWS
index bf1d287..c934cd9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,9 @@ GNU coreutils NEWS                                    -*- outline -*-
   more file arguments.  This was due to a double-free bug, introduced
   in coreutils-5.3.0.
 
+  dd bs= operands now silently override any later ibs= and obs=
+  operands, as POSIX and tradition require.
+
   A cross-partition "mv /etc/passwd ~" (by non-root) now prints
   a reasonable diagnostic.  Before, it would print this:
   "mv: cannot remove `/etc/passwd': Not a directory".
index dfd9595..ab95db4 100644 (file)
@@ -7170,7 +7170,7 @@ This makes @command{dd} write @var{bytes} per block.
 @cindex block size
 Set both input and output block sizes to @var{bytes}.
 This makes @command{dd} read and write @var{bytes} per block,
-overriding any preceding @samp{ibs} and @samp{obs} settings.
+overriding any @samp{ibs} and @samp{obs} settings.
 
 @item cbs=@var{bytes}
 @opindex cbs
index 3449e12..1a3a4e4 100644 (file)
--- a/src/dd.c
+++ b/src/dd.c
@@ -873,6 +873,7 @@ static void
 scanargs (int argc, char **argv)
 {
   int i;
+  size_t blocksize = 0;
 
   for (i = optind; i < argc; i++)
     {
@@ -923,7 +924,7 @@ scanargs (int argc, char **argv)
          else if (STREQ (name, "bs"))
            {
              invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (INPUT_BLOCK_SLOP));
-             output_blocksize = input_blocksize = n;
+             blocksize = n;
            }
          else if (STREQ (name, "cbs"))
            {
@@ -948,6 +949,9 @@ scanargs (int argc, char **argv)
        }
     }
 
+  if (blocksize)
+    input_blocksize = output_blocksize = blocksize;
+
   /* If bs= was given, both `input_blocksize' and `output_blocksize' will
      have been set to positive values.  If either has not been set,
      bs= was not given, so make sure two buffers are used. */
index 2db5c5b..513221b 100755 (executable)
@@ -74,6 +74,9 @@ if dd oflag=nolinks if=$tmp_in of=$tmp_out 2> /dev/null; then
   dd oflag=nolinks < $tmp_in > $tmp_out 2>&1 || fail=1
 fi
 
+outbytes=`echo x | dd bs=3 ibs=10 obs=10 conv=sync 2>/dev/null | wc -c`
+test "$outbytes" -eq 3 || fail=1
+
 rm -f $tmp_in $tmp_in2 $tmp_sym $tmp_out
 
 exit $fail