Re: \prompt for psql

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: \prompt for psql
Дата
Msg-id 20367.1171735163@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: \prompt for psql  ("Chad Wagner" <chad.wagner@gmail.com>)
Ответы Re: \prompt for psql  ("Chad Wagner" <chad.wagner@gmail.com>)
Список pgsql-patches
"Chad Wagner" <chad.wagner@gmail.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

В списке pgsql-patches по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: patch adding new regexp functions
Следующее
От: "Chad Wagner"
Дата:
Сообщение: Re: \prompt for psql