Skip to content

Commit 4b965f5

Browse files
committed
Fix stout/stderr paging. Do not page \h select, but page \h *.
1 parent da76711 commit 4b965f5

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/bin/psql/psql.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.79 1997/08/01 03:33:02 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.80 1997/08/01 04:07:55 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -123,7 +123,7 @@ usage(char *progname)
123123
fprintf(stderr, "\t -d dbName specify database name\n");
124124
fprintf(stderr, "\t -e echo the query sent to the backend\n");
125125
fprintf(stderr, "\t -f filename use file as a source of queries\n");
126-
fprintf(stderr, "\t -F sep set the field separator (default is "|")\n");
126+
fprintf(stderr, "\t -F sep set the field separator (default is '|')\n");
127127
fprintf(stderr, "\t -h host set database server host\n");
128128
fprintf(stderr, "\t -H turn on html3.0 table output\n");
129129
fprintf(stderr, "\t -l list available databases\n");
@@ -164,7 +164,7 @@ slashUsage(PsqlSettings * ps)
164164
pqsignal(SIGPIPE, SIG_IGN);
165165
}
166166
else
167-
fout = stderr;
167+
fout = stdout;
168168

169169
fprintf(fout, " \\? -- help\n");
170170
fprintf(fout, " \\a -- toggle field-alignment (currenty %s)\n", on(ps->opt.align));
@@ -621,15 +621,15 @@ SendQuery(bool * success_p, PsqlSettings * settings, const char *query,
621621
case PGRES_COMMAND_OK:
622622
*success_p = true;
623623
if (!settings->quiet)
624-
fprintf(stdout, "%s\n", PQcmdStatus(results));
624+
printf("%s\n", PQcmdStatus(results));
625625
break;
626626
case PGRES_COPY_OUT:
627627
*success_p = true;
628628
if (copy_out) {
629629
handleCopyOut(results, settings->quiet, copystream);
630630
} else {
631631
if (!settings->quiet)
632-
fprintf(stdout, "Copy command returns...\n");
632+
printf("Copy command returns...\n");
633633

634634
handleCopyOut(results, settings->quiet, stdout);
635635
}
@@ -693,7 +693,7 @@ toggle(PsqlSettings * settings, bool * sw, char *msg)
693693
{
694694
*sw = !*sw;
695695
if (!settings->quiet)
696-
fprintf(stderr, "turned %s %s\n", on(*sw), msg);
696+
printf("turned %s %s\n", on(*sw), msg);
697697
return *sw;
698698
}
699699

@@ -869,9 +869,9 @@ do_copy(const char *args, PsqlSettings * settings)
869869
fclose(copystream);
870870
if (!settings->quiet) {
871871
if (success)
872-
fprintf(stdout, "Successfully copied.\n");
872+
printf("Successfully copied.\n");
873873
else
874-
fprintf(stdout, "Copy failed.\n");
874+
printf("Copy failed.\n");
875875
}
876876
}
877877
}
@@ -1046,14 +1046,16 @@ do_help(const char *topic)
10461046
char *pagerenv;
10471047
FILE *fout;
10481048

1049-
if ((pagerenv = getenv("PAGER")) && (pagerenv[0] != '\0') && \
1049+
if (strcmp(topic, "*") == 0 &&
1050+
(pagerenv = getenv("PAGER")) &&
1051+
(pagerenv[0] != '\0') &&
10501052
(fout = popen(pagerenv, "w")))
10511053
{
10521054
usePipe = 1;
10531055
pqsignal(SIGPIPE, SIG_IGN);
10541056
}
10551057
else
1056-
fout = stderr;
1058+
fout = stdout;
10571059

10581060
help_found = false; /* Haven't found it yet */
10591061
for (i = 0; QL_HELP[i].cmd; i++) {
@@ -1075,7 +1077,7 @@ do_help(const char *topic)
10751077
}
10761078

10771079
if (!help_found)
1078-
printf("command not found, "
1080+
fprintf(stderr,"command not found, "
10791081
"try \\h with no arguments to see available help\n");
10801082
}
10811083
}
@@ -1291,7 +1293,7 @@ HandleSlashCmds(PsqlSettings * settings,
12911293
exit(1);
12921294
}
12931295
if (!settings->quiet)
1294-
fprintf(stderr, "field separater changed to '%s'\n", settings->opt.fieldSep);
1296+
printf("field separater changed to '%s'\n", settings->opt.fieldSep);
12951297
break;
12961298
}
12971299
case 'g': /* \g means send query */
@@ -1346,7 +1348,7 @@ HandleSlashCmds(PsqlSettings * settings,
13461348
case 'r': /* reset(clear) the buffer */
13471349
query[0] = '\0';
13481350
if (!settings->quiet)
1349-
fprintf(stderr, "buffer reset(cleared)\n");
1351+
printf("buffer reset(cleared)\n");
13501352
break;
13511353
case 's': /* \s is save history to a file */
13521354
if (!optarg)
@@ -1364,13 +1366,13 @@ HandleSlashCmds(PsqlSettings * settings,
13641366
free(settings->opt.fieldSep);
13651367
settings->opt.fieldSep = strdup("|");
13661368
if (!settings->quiet)
1367-
fprintf(stderr, "field separater changed to '%s'\n", settings->opt.fieldSep);
1369+
printf("field separater changed to '%s'\n", settings->opt.fieldSep);
13681370
} else {
13691371
if (settings->opt.fieldSep)
13701372
free(settings->opt.fieldSep);
13711373
settings->opt.fieldSep = strdup(DEFAULT_FIELD_SEP);
13721374
if (!settings->quiet)
1373-
fprintf(stderr, "field separater changed to '%s'\n", settings->opt.fieldSep);
1375+
printf("field separater changed to '%s'\n", settings->opt.fieldSep);
13741376
}
13751377
break;
13761378
case 'z': /* list table rights (grant/revoke) */

0 commit comments

Comments
 (0)