summaryrefslogtreecommitdiff
path: root/src/du.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2008-05-15 11:19:44 +0200
committerJim Meyering <meyering@redhat.com>2008-05-17 08:28:59 +0200
commit878e51ebfaf130f494957e7e6b5bce96d6e1eb13 (patch)
treee8e3e9ae473abc8c94e6d22916451f330a807605 /src/du.c
parent51243cdacacbde2c020846c22d81ab435f2f1f22 (diff)
downloadcoreutils-878e51ebfaf130f494957e7e6b5bce96d6e1eb13.tar.xz
du, wc: merge improved --files0-from=F-related diagnostics
du gave a better diagnostic for one unusual case, and wc gave a better diagnostic for a different one. Now each diagnoses both unusual cases. * src/du.c (main): Disallow '-' as file name when reading from stdin. * src/wc.c (main): Give a better diagnostic for a zero-length file name.
Diffstat (limited to 'src/du.c')
-rw-r--r--src/du.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/du.c b/src/du.c
index 668107993..55aa1fefc 100644
--- a/src/du.c
+++ b/src/du.c
@@ -1,5 +1,5 @@
/* du -- summarize disk usage
- Copyright (C) 1988-1991, 1995-2007 Free Software Foundation, Inc.
+ Copyright (C) 1988-1991, 1995-2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -977,10 +977,22 @@ main (int argc, char **argv)
if ( ! files[i])
break;
+ if (files_from && STREQ (files_from, "-") && STREQ (files[i], "-"))
+ {
+ /* Give a better diagnostic in an unusual case:
+ printf - | du --files0-from=- */
+ error (0, 0, _("when reading file names from stdin, "
+ "no file name of %s allowed"),
+ quote ("-"));
+ continue;
+ }
+
if (files[i][0])
i++;
else
{
+ /* Diagnose a zero-length file name. When it's one
+ among many, knowing the record number may help. */
if (files_from)
{
/* Using the standard `filename:line-number:' prefix here is