From 3c44e03f8cb77572911a7bf2ecbcbb3e0c27a4fc Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 16 Jun 2012 22:30:04 +0200 Subject: [PATCH] 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 --- text-utils/display.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/text-utils/display.c b/text-utils/display.c index 717565ed15..1f9a11b4c9 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) { -- 2.47.3