Commit 48e03583 authored by Tom Lane's avatar Tom Lane

Avoid reading ~/.inputrc in tab-completion test, and revert other changes.

The true explanation for Peter Geoghegan's trouble report turns out
to be that he has a ~/.inputrc that affects readline's behavior
enough to break this test.  Prevent readline from reading that file.

Also, the best way to prevent TERM from affecting the results seems
to be to unset it altogether, not to set it to "xterm".  The latter
choice licenses readline to emit xterm escape sequences, and there's
a lot of variation in exactly what it will emit.

Revert changes that attempted to account exactly for xterm escape
sequences.  We shouldn't need that with TERM unset, and it was not
looking like a maintainable solution anyway.

Discussion: https://postgr.es/m/23181.1578167938@sss.pgh.pa.us
parent 7e424781
......@@ -38,11 +38,17 @@ $node->safe_psql('postgres',
my $historyfile = "${TestLib::log_path}/010_psql_history.txt";
$ENV{PSQL_HISTORY} = $historyfile;
# Debug investigation
note "TERM is set to '" . ($ENV{TERM} || "<undef>") . "'";
# regexp to match one xterm escape sequence (CSI style only, for now)
my $escseq = "(\e\\[[0-9;]*[A-Za-z])";
# Another pitfall for developers is that they might have a ~/.inputrc
# file that changes readline's behavior enough to affect this test.
# So ignore any such file.
$ENV{INPUTRC} = '/dev/null';
# Unset $TERM so that readline/libedit won't use any terminal-dependent
# escape sequences; that leads to way too many cross-version variations
# in the output.
delete $ENV{TERM};
# Some versions of readline inspect LS_COLORS, so for luck unset that too.
delete $ENV{LS_COLORS};
# fire up an interactive psql session
my $in = '';
......@@ -107,12 +113,8 @@ check_completion(
"select \\* from my\a?tab",
"complete my<tab> to mytab when there are multiple choices");
# 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",
# some versions of readline/libedit require two tabs here, some only need one
check_completion("\t\t", "mytab123 +mytab246",
"offer multiple table choices");
check_completion("2\t", "246 ",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment