Re: \prompt for psql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Chad Wagner" <chad(dot)wagner(at)gmail(dot)com>
Cc: "Bruce Momjian" <bruce(at)momjian(dot)us>, "Magnus Hagander" <magnus(at)hagander(dot)net>, "Peter Eisentraut" <peter_e(at)gmx(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: \prompt for psql
Date: 2007-02-17 17:59:23
Message-ID: 20367.1171735163@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

"Chad Wagner" <chad(dot)wagner(at)gmail(dot)com> writes:
> Would it make sense to say:
> 1. if pset.notty is set and '-f' switch is not set then use simple_prompt
> 2. else then use gets_fromFile(stdin) <or some other alternative?>

Actually, there's another issue, which is where to send the prompt.
If we're using /dev/tty the answer is clear, but if we're proposing to
read from stdin then it's not necessarily the case that stdout (or even
stderr) is appropriate.

Arguably a prompt is useless except to a human user, so maybe the rule
is "if stdin is a tty according to pset.notty, then prompt to /dev/tty;
otherwise suppress the prompt altogether". Or we could prompt to stderr
instead of /dev/tty in this case. I'm not sure if there are plausible
use-cases where stdin leads to the terminal and stderr doesn't.

Surely there are precedents for this sort of thing in existing programs;
can anyone point to any programs that seem to get it right (or wrong)?

regards, tom lane

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Chad Wagner 2007-02-17 18:18:49 Re: \prompt for psql
Previous Message Peter Eisentraut 2007-02-17 17:12:54 Re: patch adding new regexp functions