Skip to content

Commit b8476a0

Browse files
committed
From: Andrew Martin <martin@biochemistry.ucl.ac.uk>
psql .psqlrc file startup(Andrew)
1 parent 33de29f commit b8476a0

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

src/bin/psql/psql.c

Lines changed: 29 additions & 3 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.127 1998/01/22 18:50:22 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.128 1998/01/23 19:21:11 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -2413,9 +2413,11 @@ main(int argc, char **argv)
24132413
char *singleQuery = NULL;
24142414

24152415
bool listDatabases = 0;
2416-
int successResult = 1;
2416+
int successResult = 1;
24172417
bool singleSlashCmd = 0;
2418-
int c;
2418+
int c;
2419+
2420+
char *home = NULL; /* Used to store $HOME */
24192421

24202422
MemSet(&settings, 0, sizeof settings);
24212423
settings.opt.align = 1;
@@ -2556,6 +2558,30 @@ main(int argc, char **argv)
25562558
printf(" type \\g or terminate with semicolon to execute query\n");
25572559
printf(" You are currently connected to the database: %s\n\n", dbname);
25582560
}
2561+
2562+
/*
2563+
* 20.06.97 ACRM See if we've got a /etc/psqlrc or .psqlrc file
2564+
*/
2565+
if(!access("/etc/psqlrc",R_OK))
2566+
HandleSlashCmds(&settings, "\\i /etc/psqlrc", "");
2567+
if((home = getenv("HOME"))!=NULL) {
2568+
char *psqlrc = NULL,
2569+
*line = NULL;
2570+
2571+
if((psqlrc = (char *)malloc(strlen(home) + 10))!=NULL) {
2572+
sprintf(psqlrc, "%s/.psqlrc", home);
2573+
if(!access(psqlrc, R_OK)) {
2574+
if((line = (char *)malloc(strlen(psqlrc) + 5))!=NULL) {
2575+
sprintf(line, "\\i %s", psqlrc);
2576+
HandleSlashCmds(&settings, line, "");
2577+
free(line);
2578+
}
2579+
}
2580+
free(psqlrc);
2581+
}
2582+
}
2583+
/* End of check for psqlrc files */
2584+
25592585
if (qfilename || singleSlashCmd)
25602586
{
25612587

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy