summaryrefslogtreecommitdiff
path: root/src/dd.c
diff options
context:
space:
mode:
authorPozsár Balázs <pozsy@uhulinux.hu>2012-09-24 02:39:09 +0100
committerPádraig Brady <P@draigBrady.com>2012-09-24 15:14:23 +0100
commit7331ab55fc28ac03c18cd683b7748a07dbd63f0f (patch)
treeef1b7388c8698720657d5a60ef0c9a20c7f1b87d /src/dd.c
parent2dad87f6415ec68564e934ace33496db1abc68c7 (diff)
downloadcoreutils-7331ab55fc28ac03c18cd683b7748a07dbd63f0f.tar.xz
dd: new option, status=none to suppress output statistics
* src/dd.c (STATUS_NONE): A new bitmask combining all STATUS_ options, thus used to suppress all informational output. (struct symbol_value statuses): Expose the "none" option, corresponding to the STATUS_NONE bitmask above. (print_stats): Return early if STATUS_NONE is specified. Also move the call to gethrxtime() down so that it's only called when needed. (usage): Describe the new options. * doc/coreutils.texi (dd invocation): Likewise. * NEWS: Mention the new feature. * tests/dd/misc.sh: Ensure the new option works.
Diffstat (limited to 'src/dd.c')
-rw-r--r--src/dd.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/dd.c b/src/dd.c
index de514355e..b613fcf4e 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -135,7 +135,10 @@ enum
/* Status bit masks. */
enum
{
- STATUS_NOXFER = 01
+ STATUS_NOXFER = 01,
+ STATUS_NOCOUNTS = 02,
+ STATUS_LAST = STATUS_NOCOUNTS,
+ STATUS_NONE = STATUS_LAST | (STATUS_LAST - 1)
};
/* The name of the input file, or NULL for the standard input. */
@@ -370,6 +373,7 @@ static struct symbol_value const flags[] =
static struct symbol_value const statuses[] =
{
{"noxfer", STATUS_NOXFER},
+ {"none", STATUS_NONE},
{"", 0}
};
@@ -536,7 +540,8 @@ Copy a file, converting and formatting according to the operands.\n\
oflag=FLAGS write as per the comma separated symbol list\n\
seek=N skip N obs-sized blocks at start of output\n\
skip=N skip N ibs-sized blocks at start of input\n\
- status=noxfer suppress transfer statistics\n\
+ status=WHICH WHICH info to suppress outputting to stderr;\n\
+ 'noxfer' suppresses transfer stats, 'none' suppresses all\n\
"), stdout);
fputs (_("\
\n\
@@ -664,7 +669,6 @@ multiple_bits_set (int i)
static void
print_stats (void)
{
- xtime_t now = gethrxtime ();
char hbuf[LONGEST_HUMAN_READABLE + 1];
int human_opts =
(human_autoscale | human_round_to_nearest
@@ -672,6 +676,9 @@ print_stats (void)
double delta_s;
char const *bytes_per_second;
+ if ((status_flags & STATUS_NONE) == STATUS_NONE)
+ return;
+
fprintf (stderr,
_("%"PRIuMAX"+%"PRIuMAX" records in\n"
"%"PRIuMAX"+%"PRIuMAX" records out\n"),
@@ -697,6 +704,7 @@ print_stats (void)
w_bytes,
human_readable (w_bytes, hbuf, human_opts, 1, 1));
+ xtime_t now = gethrxtime ();
if (start_time < now)
{
double XTIME_PRECISIONe0 = XTIME_PRECISION;