Proposal: psql force prompting on notty - Mailing list pgsql-hackers

From Michael Mauger
Subject Proposal: psql force prompting on notty
Date
Msg-id 20031101065144.28680.qmail@web60305.mail.yahoo.com
Whole thread Raw
Responses Re: Proposal: psql force prompting on notty  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
I'm the maintainer of sql.el in GNU Emacs.  On both the Mac OS X
and the Windows/Cygwin platform we've had reports that psql run
under Emacs does not issue a prompt for commands.

I did a little research and it appears that the cause is that
pset.notty is being set to false because stdin/stdout are not
a tty (pgsql-server/src/bin/psql/startup.c).  I'd like to
propose that an option be added to the psql command line to
override the detection of the tty and force the prompting for
commands on stdin.

I believe the attached patch should add the option -I to psql
and force the prompt to appear as if it were an interactive
session regardless of the state of stdin/stdout.  I do not
have a configuration available to properly test this however.

Please be sure to include me in any replies since I do not
subscribe to this list.  TIA.

-- Michael

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com--- pgsql-server/src/bin/psql/startup.c    29 Sep 2003 18:21:33 -0000    1.80
+++ pgsql-server/src/bin/psql/startup.c    01 Nov 2003 06:10:42 -0000
@@ -322,6 +322,7 @@
         {"field-separator", required_argument, NULL, 'F'},
         {"host", required_argument, NULL, 'h'},
         {"html", no_argument, NULL, 'H'},
+        {"interactive", no_argument, NULL, 'I'},
         {"list", no_argument, NULL, 'l'},
         {"no-readline", no_argument, NULL, 'n'},
         {"output", required_argument, NULL, 'o'},
@@ -352,7 +353,7 @@

     memset(options, 0, sizeof *options);

-    while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:h:Hlno:p:P:qR:sStT:uU:v:VWxX?",
+    while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:h:HlMno:p:P:qR:sStT:uU:v:VWxX?",
                             long_options, &optindex)) != -1)
     {
         switch (c)
@@ -395,7 +396,10 @@
             case 'H':
                 pset.popt.topt.format = PRINT_HTML;
                 break;
+            case 'I':
+                pset.notty = 0;
+                break;
             case 'l':
                 options->action = ACT_LIST_DB;
                 break;
--- pgsql-server/src/bin/psql/help.c    02 Oct 2003 06:39:31 -0000    1.81
+++ pgsql-server/src/bin/psql/help.c    01 Nov 2003 06:29:50 -0000
@@ -103,6 +103,7 @@
     puts(_("  -a              echo all input from script"));
     puts(_("  -e              echo commands sent to server"));
     puts(_("  -E              display queries that internal commands generate"));
+    puts(_("  -I              force interactive prompting for input"));
     puts(_("  -q              run quietly (no messages, only query output)"));
     puts(_("  -o FILENAME     send query results to file (or |pipe)"));
     puts(_("  -n              disable enhanced command line editing (readline)"));

pgsql-hackers by date:

Previous
From: "Cuong Bui (lokishop.nl)"
Date:
Subject: Re: Vacuum thoughts
Next
From: Peter Eisentraut
Date:
Subject: Re: Proposal: psql force prompting on notty