Bug 566079 - dd should have a --quiet option
Summary: dd should have a --quiet option
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: coreutils
Version: 12
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Ondrej Vasik
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-02-17 04:57 UTC by JW
Modified: 2010-02-18 07:15 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-02-17 12:43:12 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description JW 2010-02-17 04:57:29 UTC
Description of problem:
dd should have a --quiet option to suppress the often unimportant statistical output (ie. 1+0 records in, 1+0 records out, 4096 bytes ...).  Why you might ask?  Because standard error is being used by dd for something other than errors.  If one is to redirect standard error to /dev/null to get rid of the record count information then one might not see important actual error messages.

Version-Release number of selected component (if applicable):
coreutils-7.6-8

How reproducible:
Always

Steps to Reproduce:
1. dd if=/dev/zero count=1 of=/dev/null
2. dd if=/dev/zero count=1 of=/dev/null >/dev/null
3. dd if=/dev/zero count=1 of=/dev/null 2>/dev/null
4. dd if=/dev/zerooooo count=1 of=/dev/null 2>/dev/null
5. dd --quiet if=/dev/zerooooo count=1 of=/dev/null

  
Actual results:
1.
  1+0 records in
  1+0 records out
  512 bytes (512 B) copied, 2.3633e-05 s, 21.7 MB/
2. <ditto>
3.
4.
5. dd: invalid option -- '-' (THIS IS ANOTHER BUG - should be '--quiet')

Expected results:
1.
  1+0 records in
  1+0 records out
  512 bytes (512 B) copied, 2.3633e-05 s, 21.7 MB/
2. <ditto>
3.
4.
5. dd: opening `/dev/zerooooo': No such file or directory

Additional info:
The record count output is relatively pointless, but in any case it would make more sense to only show such information if the user requested it (eg. with -v/--verbose).  I doubt that there are many scripts out there processing stderr to extract record counts, but many people would be used to seeing dd output its mostly useless information. Let's face it, 'cp' doesn't need to give byte count or record count feedback so you can be sure it actually did something.  It simply isn't the normal *nix way of doing things.

Anyhow there currently isn't a sensible way to separate actual error messages from the generally unnecessary record count feedback.  There should be.

After all, somebody once decided to add the '--help' and '--version' options, and the world hasn't collapsed as a result.

Comment 1 Ondrej Vasik 2010-02-17 07:39:55 UTC
In POSIX is written that dd shall write that diagnostic statistical output about dd-ed records to stderr upon successful completition (https://www.opengroup.org/onlinepubs/009695399/utilities/dd.html). Therefore that option will not follow POSIX and therefore is IMHO unlikely to be added.

There is already a difference between succesful completition of dd and error with output you want. That difference is exitcode - "$?" ... for 0 you want to drop stderr, for nonzero you want to show it. This should be IMHO easy to achieve if you really want it.

Comment 2 Kamil Dudka 2010-02-17 12:13:33 UTC
(In reply to comment #0)
> Description of problem:
> dd should have a --quiet option to suppress the often unimportant statistical
> output (ie. 1+0 records in, 1+0 records out, 4096 bytes ...).  Why you might

You can use the option 'status=noxfer' to suppress the third line, which may be useful for scripts parsing the error output of dd.  If you don't need the error output, it's safe to redirect it to /dev/null, as you already figured out.

Comment 3 Ondrej Vasik 2010-02-17 12:43:12 UTC
> 5. dd: invalid option -- '-' (THIS IS ANOTHER BUG - should be '--quiet')

Not really bug... just the way how getopt_long behaves and parses argv. If you think that there is a way how to make it better without regressions, feel free to propose patch on bug-gnulib .

Closing this bugreport NOTABUG - input/output records required by POSIX, transfer status could be supressed easily. If you want to filter input/output records from stderr, write a simple wrapper script around and do not show stderr for the case of dd exit code 0.


Note You need to log in before you can comment on or make changes to this bug.