Ignore system psqlrc and local .psqlrc when dropping test databases (#22315)

Depending on your particular .psqlrc customizations, omitting the -X
flag from psql invocations may include formatting details in the output:

  # psql -c 'copy (select 1) to stdout'
  Border style is 2.
  Line style is unicode.
  1
  Time: 0.553 ms

That disrupts downstream tools like grep. The -X flag skips reading the
system psqlrc and local .psqlrc file, which fixes the issue:

  # psql -Xc 'copy (select 1) to stdout'
  1
This commit is contained in:
flying-robot 2021-06-23 09:21:55 -04:00 committed by GitHub
parent d307934704
commit 4e7c93b3c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@
set -eo pipefail
for dbname in $(psql -c "copy (select datname from pg_database where datname like 'sourcegraph-test-%') to stdout"); do
for dbname in $(psql -Xc "copy (select datname from pg_database where datname like 'sourcegraph-test-%') to stdout"); do
dropdb "$dbname"
echo "dropped $dbname"
done