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 1ino1W-0003ZK-4Y for pgsql-hackers@arkaria.postgresql.org; Sat, 04 Jan 2020 18:19:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ino1U-0004ml-JB for pgsql-hackers@arkaria.postgresql.org; Sat, 04 Jan 2020 18:19:40 +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 1ino1U-0004md-6k for pgsql-hackers@lists.postgresql.org; Sat, 04 Jan 2020 18:19:40 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ino1R-0002HW-K1 for pgsql-hackers@postgresql.org; Sat, 04 Jan 2020 18:19:39 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 004IJSG9025740; Sat, 4 Jan 2020 13:19:29 -0500 From: Tom Lane To: Peter Geoghegan cc: Robert Haas , Christoph Berg , PostgreSQL Hackers Subject: Re: pgsql: Add basic TAP tests for psql's tab-completion logic. In-reply-to: <9256.1578121229@sss.pgh.pa.us> References: <20200103170226.GB32629@msg.df7cb.de> <26339.1578072930@sss.pgh.pa.us> <20200103174839.GD32629@msg.df7cb.de> <22669.1578104202@sss.pgh.pa.us> <25298.1578106280@sss.pgh.pa.us> <3055.1578115809@sss.pgh.pa.us> <8038.1578119995@sss.pgh.pa.us> <9256.1578121229@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sat, 04 Jan 2020 02:00:29 -0500" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <25718.1578161953.0@sss.pgh.pa.us> Date: Sat, 04 Jan 2020 13:19:28 -0500 Message-ID: <25739.1578161968@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25718.1578161953.1@sss.pgh.pa.us> I wrote: > Meh. I must be too tired to get the regexp syntax right. Looking closer, I see that your actual output included *both* spaces and escape sequences between the table names, so it needs to be more like the attached. Also, I apparently misread the control sequences. What they look like in the light of morning is \e[0m Character Attributes = Normal (no bold, color, etc) \e[K Erase in Line to Right So now I'm thinking again that there must be something about your colorized setup that triggers use of at least the first one. But why didn't clearing the relevant environment variables change anything? regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="allow-escape-sequences-2.patch"; charset="us-ascii" Content-ID: <25718.1578161953.2@sss.pgh.pa.us> Content-Description: allow-escape-sequences-2.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/bin/psql/t/010_tab_completion.pl b/src/bin/psql/t/010_tab= _completion.pl index 96221f8..ed9e9e1 100644 --- a/src/bin/psql/t/010_tab_completion.pl +++ b/src/bin/psql/t/010_tab_completion.pl @@ -38,6 +38,12 @@ $node->safe_psql('postgres', my $historyfile =3D "${TestLib::log_path}/010_psql_history.txt"; $ENV{PSQL_HISTORY} =3D $historyfile; = +# Ensure that readline/libedit puts out xterm escapes, not something else= . +$ENV{TERM} =3D 'xterm'; + +# regexp to match one xterm escape sequence (CSI style only, for now) +my $escseq =3D "(\e\\[[0-9;]*[A-Za-z])"; + # fire up an interactive psql session my $in =3D ''; my $out =3D ''; @@ -101,8 +107,12 @@ check_completion( "select \\* from my\a?tab", "complete my to mytab when there are multiple choices"); = -# some versions of readline/libedit require two tabs here, some only need= one -check_completion("\t\t", "mytab123 +mytab246", +# some versions of readline/libedit require two tabs here, some only need= one. +# also, some might issue escape sequences to reposition the cursor, clear= the +# line, etc, instead of just printing some spaces. +check_completion( + "\t\t", + "mytab$escseq*123( |$escseq)+mytab$escseq*246", "offer multiple table choices"); = check_completion("2\t", "246 ", ------- =_aaaaaaaaaa0--