? cscope.out
Index: doc/src/sgml/ref/psql-ref.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v
retrieving revision 1.183
diff -u -p -c -r1.183 psql-ref.sgml
*** doc/src/sgml/ref/psql-ref.sgml	1 Feb 2007 19:10:24 -0000	1.183
--- doc/src/sgml/ref/psql-ref.sgml	17 Feb 2007 18:01:36 -0000
*************** lo_import 152801
*** 1430,1435 ****
--- 1430,1460 ----
        </varlistentry>
  
        <varlistentry>
+         <term><literal>\prompt <replaceable class="parameter">name</replaceable> [ <replaceable class="parameter">text</replaceable> ]</literal></term>
+         <listitem>
+         <para>
+         Prompts the user for input on variable <replaceable
+ 	class="parameter">name</>, and sets the variable to the value that
+ 	the user has input.  Optionally you may define the
+ 	<replaceable class="parameter">text</> for the prompt, if none is
+ 	provided then a default prompt text will be presented.
+         </para>
+ 
+ 	<para>
+ 	If psql is executed with a redirected input then when this command
+ 	is used the input will be requested directly from the console,
+ 	unless the <option>-f</> command line switch was used then input will
+ 	be requested from standard input.
+ 	</para>
+ 
+ 	<para>
+ 	If psql is executed with the <option>-q</> command line switch then
+ 	prompts (regardless if they are provided) will not be displayed.
+ 	</para>
+         </listitem>
+       </varlistentry>
+ 
+       <varlistentry>
          <term><literal>\pset <replaceable class="parameter">parameter</replaceable> [ <replaceable class="parameter">value</replaceable> ]</literal></term>
  
          <listitem>
Index: src/bin/psql/command.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/psql/command.c,v
retrieving revision 1.177
diff -u -p -c -r1.177 command.c
*** src/bin/psql/command.c	5 Jan 2007 22:19:49 -0000	1.177
--- src/bin/psql/command.c	17 Feb 2007 18:01:37 -0000
*************** exec_command(const char *cmd,
*** 712,717 ****
--- 712,772 ----
  		free(pw2);
  	}
  
+ 	/* \prompt -- prompt and set variable */
+ 	else if (strcmp(cmd, "prompt") == 0)
+ 	{
+ 		char	   *opt = psql_scan_slash_option(scan_state,
+ 					OT_NORMAL, NULL, false);
+ 
+ 		if (!opt)
+ 		{
+ 			psql_error("\\%s: missing required argument\n", cmd);
+ 			success = false;
+ 		}
+ 		else
+ 		{
+ 			char	   *prompt_text = NULL;
+ 			char	   *result;
+ 
+ 			if (!pset.quiet)
+ 			{
+ 				prompt_text = psql_scan_slash_option(scan_state,
+ 					OT_WHOLE_LINE, NULL, false);
+ 
+ 				if (!prompt_text)
+ 				{
+ 					prompt_text = malloc(strlen(opt) + 32);
+ 					sprintf(prompt_text, "Enter value for \"%s\": ", opt);
+ 				}
+ 			}
+ 
+ 			if (pset.notty && !pset.inputfile)
+ 			{
+ 				result = simple_prompt(prompt_text, 4096, true);
+ 			}
+ 			else
+ 			{
+ 				if (prompt_text)
+ 				{
+ 					fputs(_(prompt_text), stdout);
+ 					fflush(stdout);
+ 				}
+ 				result = gets_fromFile(stdin);
+ 			}
+ 
+ 			if (!SetVariable(pset.vars, opt, result))
+ 			{
+ 				psql_error("\\%s: error\n", cmd);
+ 				success = false;
+ 			}
+ 
+ 			free(result);
+ 			if (prompt_text)
+ 				free(prompt_text);
+ 			free(opt);
+ 		}
+ 	}
+ 
  	/* \pset -- set printing parameters */
  	else if (strcmp(cmd, "pset") == 0)
  	{
Index: src/bin/psql/help.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/psql/help.c,v
retrieving revision 1.116
diff -u -p -c -r1.116 help.c
*** src/bin/psql/help.c	5 Jan 2007 22:19:49 -0000	1.116
--- src/bin/psql/help.c	17 Feb 2007 18:01:37 -0000
*************** slashUsage(unsigned short int pager)
*** 161,167 ****
  {
  	FILE	   *output;
  
! 	output = PageOutput(67, pager);
  
  	/* if you add/remove a line here, change the row count above */
  
--- 161,167 ----
  {
  	FILE	   *output;
  
! 	output = PageOutput(69, pager);
  
  	/* if you add/remove a line here, change the row count above */
  
*************** slashUsage(unsigned short int pager)
*** 184,189 ****
--- 184,191 ----
  	fprintf(output, _("  \\timing        toggle timing of commands (currently %s)\n"),
  			ON(pset.timing));
  	fprintf(output, _("  \\unset NAME    unset (delete) internal variable\n"));
+ 	fprintf(output, _("  \\prompt NAME [TEXT]\n"
+ 					  "                 prompt user and set internal variable\n"));
  	fprintf(output, _("  \\! [COMMAND]   execute command in shell or start interactive shell\n"));
  	fprintf(output, "\n");
  
Index: src/bin/psql/tab-complete.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/psql/tab-complete.c,v
retrieving revision 1.158
diff -u -p -c -r1.158 tab-complete.c
*** src/bin/psql/tab-complete.c	7 Feb 2007 00:52:35 -0000	1.158
--- src/bin/psql/tab-complete.c	17 Feb 2007 18:01:38 -0000
*************** psql_completion(char *text, int start, i
*** 542,548 ****
  		"\\e", "\\echo", "\\encoding",
  		"\\f", "\\g", "\\h", "\\help", "\\H", "\\i", "\\l",
  		"\\lo_import", "\\lo_export", "\\lo_list", "\\lo_unlink",
! 		"\\o", "\\p", "\\password", "\\pset", "\\q", "\\qecho", "\\r",
  		"\\set", "\\t", "\\T",
  		"\\timing", "\\unset", "\\x", "\\w", "\\z", "\\!", NULL
  	};
--- 542,548 ----
  		"\\e", "\\echo", "\\encoding",
  		"\\f", "\\g", "\\h", "\\help", "\\H", "\\i", "\\l",
  		"\\lo_import", "\\lo_export", "\\lo_list", "\\lo_unlink",
! 		"\\o", "\\p", "\\password", "\\prompt", "\\pset", "\\q", "\\qecho", "\\r",
  		"\\set", "\\t", "\\T",
  		"\\timing", "\\unset", "\\x", "\\w", "\\z", "\\!", NULL
  	};
