From 76efcab2f936fe375ad1106cd56c16a70137553d Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Wed, 3 Jun 2020 11:24:41 +0800 Subject: [PATCH] pgsql: Check for pg_config existence pg_config isn't installed by default on many systems, and is usually part of postgresql-libs-devel or some such, leading to needless "pg_config not found" errors on completion. --- src/_pgsql_utils | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/_pgsql_utils b/src/_pgsql_utils index dff7743..cbe2b8e 100644 --- a/src/_pgsql_utils +++ b/src/_pgsql_utils @@ -147,10 +147,9 @@ _pgsql_databases () { _pgsql_get_identity local _pgsql_services _pgsql_service_files - _pgsql_service_files=( - ~/.pg_service.conf - $(pg_config --sysconfdir)/pg_service.conf - ) + _pgsql_service_files=(~/.pg_service.conf) + (( $+commands[pg_config] )) && _pgsql_service_files+=$(pg_config --sysconfdir)/pg_service.conf + _pgsql_services=$( grep -h '^\[.*\]' $_pgsql_service_files 2>/dev/null \ | sed -e 's/^\[/service=/' -e 's/\].*$//' )