All in all, after testing this for a bit, I think this patch is a clear
improvement over the statu quo. Thanks for working on this.
I suggest to indicate in complete_from_files where to find the hook
functions it refers to (say "see quote_file_name, below", or something.)
I tested this on libreadline 7.x (where #define
HAVE_RL_FILENAME_COMPLETION_FUNCTION 1). I noticed that if I enter a
filename that doesn't exist and then <tab>, it adds a closing quote.
Bash manages to do nothing somehow, which is the desired behavior IMO.
(I tried to make sense of these hooks, but couldn't readily and I don't
have the readline documentation installed, so I have no opinion on
whether this problem is fixable. Maybe the trick is to let
quote_if_needed know that this is a completion for a filename, and have
it test for file existence?)
Also, some commands such as \cd want a directory rather than just any
file. Not sure rl_filename_completion_function has a way to pass this
down. (This point is a bit outside this patch's charter perhaps, but
may as well think about it since we're here ...)
I don't quite understand why a readline library that doesn't have
rl_filename_completion_function is known to have a
filename_completion_function, ie. this bit
#ifdef HAVE_RL_FILENAME_COMPLETION_FUNCTION
#define filename_completion_function rl_filename_completion_function
#else
/* decl missing in some header files, but function exists anyway */
extern char *filename_completion_function();
#endif
What's going on here? How does this ever work?
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services