]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hexdump: print sensible message when all input file arguments fail
authorSami Kerola <kerolasa@iki.fi>
Sat, 16 Jun 2012 20:30:04 +0000 (22:30 +0200)
committerSami Kerola <kerolasa@iki.fi>
Sun, 17 Jun 2012 15:59:59 +0000 (17:59 +0200)
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>
text-utils/display.c

index 717565ed154e47eb4b0e5dfd2ff005d0b1d50e16..1f9a11b4c92ce59f3cc867892628b4707a7d1d40 100644 (file)
@@ -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) {