On 1/30/15 2:09 PM, Jonathan Hankins wrote: > A test with the POSIX S_ISREG macro on HISTFILE will determine if it, or > the file it points to in the case of a symlink, is a regular file. > > Just looked through the source, and it looks like general.c:file_exists() > does not do any special handling of non-regular files, and > lib/readline/histfile.c:history_do_write() calls open() and rename() on > HISTFILE without checking if it is a non-regular file, which I imagine > could lead to various "bad things" in the case of pipes, char and block > devices, etc. such as what the OP pointed about about "/dev/null".
Well, like always, it depends. The current implementation allows a user to use a named pipe with a different program running to be a `history file'. That flexibility can be valuable. I don't think that readline should be attempting to do backups of non- regular files, though. The history file truncation code, which is called when HISTFILESIZE is changed, already rejects attempts to use non-regular files. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/