Wednesday, July 16, 2008

Re: [HACKERS] .psqlrc output for \pset commands

Index: src/bin/psql/startup.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/startup.c,v
retrieving revision 1.149
diff -c -c -r1.149 startup.c
*** src/bin/psql/startup.c 1 Jul 2008 00:08:18 -0000 1.149
--- src/bin/psql/startup.c 17 Jul 2008 00:44:22 -0000
***************
*** 281,292 ****
*/
else
{
if (!options.no_psqlrc)
process_psqlrc(argv[0]);
!
! connection_warnings();
if (!pset.quiet && !pset.notty)
! printf(_("Type \"help\" for help.\n\n"));
if (!pset.notty)
initializeInput(options.no_readline ? 0 : 1);
if (options.action_string) /* -f - was used */
--- 281,294 ----
*/
else
{
+ connection_warnings();
+ if (!pset.quiet && !pset.notty)
+ printf(_("Type \"help\" for help.\n"));
if (!options.no_psqlrc)
process_psqlrc(argv[0]);
! /* output newline here because .psqlrc might output something */
if (!pset.quiet && !pset.notty)
! printf("\n");
if (!pset.notty)
initializeInput(options.no_readline ? 0 : 1);
if (options.action_string) /* -f - was used */
Gregory Stark wrote:
> "Bruce Momjian" <bruce@momjian.us> writes:
>
> > In my .psqlrc I have:
> >
> > \pset format wrapped
> >
> > and this outputs this on psql startup:
> >
> > $ psql test
> > --> Output format is wrapped.
> > psql (8.4devel)
> > Type "help" for help.
> >
> > Is this desirable? \set QUIET at the top of .psqlrc fixes it, but I am
> > wondering if we should be automatically doing quiet while .psqlrc is
> > processed.
>
> I was wondering about this myself, but I'm still not used to the new banner.
> It seems kind of... curt. Perhaps it should just be a single line instead of
> two lines both around 20 characters...
>
> Anyways the thing that struck me as odd was the messages appearing *before*
> the header. It seems to me the header should print followed by .psqlrc output
> followed by normal output.

Do you like this better?

$ psql test
psql (8.4devel)
Type "help" for help.
Output format is wrapped.

test=>

The attached patch accomplishes this.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

No comments: