Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1if0pW-00034p-5b for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Dec 2019 12:10:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1if0pS-0007hV-Uo for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Dec 2019 12:10:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1if0pS-0007gh-Dy for pgsql-hackers@lists.postgresql.org; Wed, 11 Dec 2019 12:10:54 +0000 Received: from mail-vs1-xe44.google.com ([2607:f8b0:4864:20::e44]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1if0pP-0002q8-J3 for pgsql-hackers@lists.postgresql.org; Wed, 11 Dec 2019 12:10:53 +0000 Received: by mail-vs1-xe44.google.com with SMTP id l24so15528943vsr.12 for ; Wed, 11 Dec 2019 04:10:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=9fm3OQTCqZ0TjRu7FaHa5IsRUjeSVBEIL4+TbJ9SmIQ=; b=vC6VYWruox2RlNQj37q8Qwyi96X4LJua8uj0fyyIszQh8G0N++ur21XzwhonM5kMOp jRpRhD8W+TXcTu8CVkylEJSqadRQwEA/EfIeo7qmUjY9214aADQVv0R+YMz70iFNcv6p 4+rg1RhHN1PSIR09Xa1pvtaSIFUImndzSakn6Kf8+xPBzwQpPjfX+JXotqkOHsaM1+GJ cDU0+BonJDuLH7QDsac1eDWktrflwQNM5B0wVcE4O/vjrZrFyr8BMmN+3oGE2Iy5v5Nr 2nZO1/JiS7tNrTq8LN45NLoEkAa37bnVqp4u8qnZwRC1yXsKXTGPr4LOdqbbbbFZ1yBa liiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=9fm3OQTCqZ0TjRu7FaHa5IsRUjeSVBEIL4+TbJ9SmIQ=; b=pwo1by7gzjVWl9+14Se6wS87Rczvf7653WQZozKBKpd6XdBKvkIEqe+9GY68YsMDGV PX8VElYjC3lX9bVKRHS5qmMQnb88j4ZtZX2N1DxBznJp0EDAHBaeLDFQYjZNe3Unp0Ea 1oaoETg4FuyZMtMeOaMeOhpOnIFhxqKZ5ekvpoJy3vXzXL85hPEjXiLGf8GXj/and78/ BHHiB3A3xkGLTF2TRNls40ARqMiEg6pJ6xqXLTjBqdIbjKpk5HRmSqi2QhsJh9nwsMs5 Ln4SeyAK3J7K5i9EItsdEmlizFxUHjLWYwfG6gPj9L4Yyj/o9qol76s/sxW//nXoz1// T0vA== X-Gm-Message-State: APjAAAXgHYkEP2pSKDVHxZHoyD+DxEtabdHJQ4hdUriyXhZYaVdyU4tA T+3TyGKFutnj/q0oW0t+U+R/jtLhycHirA== X-Google-Smtp-Source: APXvYqyZa5hnKVFFRaHh98f17RFeRQHqEhJTETC1EB0/lMgt9ETKgvtwOoL3nilvJM7FPhUVlLX9ew== X-Received: by 2002:a67:ff82:: with SMTP id v2mr2162629vsq.35.1576066249905; Wed, 11 Dec 2019 04:10:49 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([190.217.182.133]) by smtp.gmail.com with ESMTPSA id u4sm967403vsl.3.2019.12.11.04.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 04:10:47 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 814E730093A; Tue, 10 Dec 2019 22:55:52 -0300 (-03) Date: Tue, 10 Dec 2019 22:55:52 -0300 From: Alvaro Herrera To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org, steven.winfield@cantabcapital.com Subject: Re: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes Message-ID: <20191211015552.GA6301@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1628.1572820800@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 , 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