Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dc565af

Browse files
committed
Allow 'help' in psql to show \? help, for novice assistance.
Greg Sabino Mullane
1 parent a051ab0 commit dc565af

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/bin/psql/help.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.124 2008/03/29 19:40:12 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.125 2008/04/04 17:42:43 momjian Exp $
77
*/
88
#include "postgres_fe.h"
99

@@ -188,6 +188,7 @@ slashUsage(unsigned short int pager)
188188
ON(pset.timing));
189189
fprintf(output, _(" \\unset NAME unset (delete) internal variable\n"));
190190
fprintf(output, _(" \\! [COMMAND] execute command in shell or start interactive shell\n"));
191+
fprintf(output, _(" \\? display this help output\n"));
191192
fprintf(output, "\n");
192193

193194
fprintf(output, _("Query Buffer\n"));

src/bin/psql/mainloop.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
*
44
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.87 2008/01/01 19:45:56 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.88 2008/04/04 17:42:43 momjian Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "mainloop.h"
1010

1111

1212
#include "command.h"
1313
#include "common.h"
14+
#include "help.h"
1415
#include "input.h"
1516
#include "settings.h"
1617

@@ -171,6 +172,16 @@ MainLoop(FILE *source)
171172
continue;
172173
}
173174

175+
/* A request for help? Be friendly and show them the slash way of doing things */
176+
if (pset.cur_cmd_interactive && query_buf->len == 0 &&
177+
pg_strncasecmp(line, "help", 4) == 0 &&
178+
(line[4] == '\0' || line[4] == ';' || isspace(line[4])))
179+
{
180+
free(line);
181+
slashUsage(pset.popt.topt.pager);
182+
continue;
183+
}
184+
174185
/* echo back if flag is set */
175186
if (pset.echo == PSQL_ECHO_ALL && !pset.cur_cmd_interactive)
176187
puts(line);

0 commit comments

Comments
 (0)