bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Builtin history -r does not work with named pipes (i.e. GNU readline's h


From: Eduardo Bustamante
Subject: Builtin history -r does not work with named pipes (i.e. GNU readline's histfile.c read_history_range)
Date: Tue, 23 May 2017 10:32:50 -0500

(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

[Prev in Thread] Current Thread [Next in Thread]