(I think this is a good problem for Pranav to tackle if you consider
this to be a bug, Chet).

The problem is that fstat(2) will return an st_size of 0 if the file
is non-regular. I think that the easiest path here is to goto
`error_and_exit' if `file' is not a regular file (and perhaps print a
useful error message?).

(gdb) r -c 'history -r <(echo foo)'
Starting program: /home/dualbus/src/gnu/bash-build/bash -c 'history -r
<(echo foo)'

Breakpoint 1, read_history_range (filename=0x82a9e8 "/dev/fd/63",
from=0, to=-1) at ../../../bash/lib/readline/histfile.c:270
270       int overflow_errno = EFBIG;
(gdb) n
277       history_lines_read_from_file = 0;
(gdb) n
279       buffer = last_ts = (char *)NULL;
(gdb) n
280       input = history_filename (filename);
(gdb) n
281       file = input ? open (input, O_RDONLY|O_BINARY, 0666) : -1;
(gdb) n
283       if ((file < 0) || (fstat (file, &finfo) == -1))
(gdb) n
286       file_size = (size_t)finfo.st_size;
(gdb) n
289       if (file_size != finfo.st_size || file_size + 1 < file_size)
(gdb) n
295       if (file_size == 0)
(gdb) n
297           free (input);
(gdb) n
298           return 0; /* don't waste time if we don't have to */

This was reported by Freenode user `merijn' in #bash

Reply via email to