pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org
Cc: steven.winfield@cantabcapital.com
Subject: Re: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes
Date: Tue, 10 Dec 2019 22:55:52 -0300
Message-ID: <20191211015552.GA6301@alvherre.pgsql> (raw)
In-Reply-To: <1628.1572820800@sss.pgh.pa.us>

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





view thread (31+ messages)  latest in thread

Message-ID: <20191211015552.GA6301@alvherre.pgsql>
Permalink:  ../20191211015552.GA6301@alvherre.pgsql/
Also on:    postgresql.org/message-id/20191211015552.GA6301@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: alvherre@2ndquadrant.com, tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org, steven.winfield@cantabcapital.com
  Subject: Re: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes
  In-Reply-To: <20191211015552.GA6301@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox