summaryrefslogtreecommitdiffstats
path: root/text-utils/display.c
diff options
context:
space:
mode:
authorSami Kerola2012-06-16 22:30:04 +0200
committerSami Kerola2012-06-17 17:59:59 +0200
commit3c44e03f8cb77572911a7bf2ecbcbb3e0c27a4fc (patch)
tree06bfa773ba06cdee083af6df4812c66468828c94 /text-utils/display.c
parentmount: (new) use exclusive_option() (diff)
downloadkernel-qcow2-util-linux-3c44e03f8cb77572911a7bf2ecbcbb3e0c27a4fc.tar.gz
kernel-qcow2-util-linux-3c44e03f8cb77572911a7bf2ecbcbb3e0c27a4fc.tar.xz
kernel-qcow2-util-linux-3c44e03f8cb77572911a7bf2ecbcbb3e0c27a4fc.zip
hexdump: print sensible message when all input file arguments fail
Earlier hexdump printed unnecessary, and perhaps even misleading, 'bad file descriptor' message. $ hexdump foobar hexdump: foobar: No such file or directory hexdump: foobar: Bad file descriptor The message is changed to $ hexdump foobar hexdump: foobar: No such file or directory hexdump: all input file arguments failed Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'text-utils/display.c')
-rw-r--r--text-utils/display.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/text-utils/display.c b/text-utils/display.c
index 717565ed1..1f9a11b4c 100644
--- a/text-utils/display.c
+++ b/text-utils/display.c
@@ -42,6 +42,7 @@
#include "hexdump.h"
#include "xalloc.h"
#include "c.h"
+#include "nls.h"
static void doskip(const char *, int);
static u_char *get(void);
@@ -257,6 +258,10 @@ get(void)
eaddress = address + nread;
return(curp);
}
+ if (fileno(stdin) == -1) {
+ warnx(_("all input file arguments failed"));
+ return(NULL);
+ }
n = fread((char *)curp + nread, sizeof(unsigned char),
length == -1 ? need : min(length, need), stdin);
if (!n) {