From: Sami Kerola Date: Sat, 16 Jun 2012 20:30:04 +0000 (+0200) Subject: hexdump: print sensible message when all input file arguments fail X-Git-Tag: v2.22-rc1~267^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3c44e03f8cb77572911a7bf2ecbcbb3e0c27a4fc;p=thirdparty%2Futil-linux.git 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 --- 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) {