Skip site navigation (1) Skip section navigation (2)

Re: BUG #4040: psql should provide option to not prompt forpassword

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Mika Fischer <mf+ubuntu(at)zoopnet(dot)de>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4040: psql should provide option to not prompt forpassword
Date: 2008-03-17 14:43:37
Message-ID: 20080317144337.GD4317@alvh.no-ip.org (view raw or flat)
Thread:
Lists: pgsql-bugs
Mika Fischer wrote:

> I'm currently working on the bash-completion package. The problem with
> postgresql is that psql cannot safely be called because there is no way to
> know whether it will prompt for a password and there is also no way to avoid
> the prompt.

Hmm, why do you need to connect to a database?  Some time ago I came up
with this:

_postgres()
{
        local cur;
        COMPREPLY=()
        cur=${COMP_WORDS[COMP_CWORD]}
        prev=${COMP_WORDS[COMP_CWORD-1]}
        if [ "$prev" == "-c" ]; then
                COMPREPLY=($(compgen -S= -onospace -W '`command postgres --describe-config | cut -d"	" -f1`' -- $cur));
                return 0
        fi
        COMPREPLY=($(compgen -W '-A -B -c -d -D -e -E -F -N -o -P -s -S -f -i -O -t -W --describe-config --help --version' -- $cur))
        return 0
}
complete -F _postgres postgres postmaster

What else do you need?

(Hmm, it doesn't work correctly in the french locale ... it seems
someone decided to add some newlines in there.)

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2008-03-17 14:48:35
Subject: Re: BUG #4040: psql should provide option to not prompt for password
Previous:From: Tom LaneDate: 2008-03-17 14:35:53
Subject: Re: BUG #4039: server closed the connection when use function "makeline_garray"

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group