aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1998-01-23 19:21:11 +0000
committerMarc G. Fournier <scrappy@hub.org>1998-01-23 19:21:11 +0000
commitb8476a09fe83f83050a528bd9ca10d37fdf3a727 (patch)
tree1649b9f013b7118376e29b2510f59967688ec991
parent33de29fc45bc219d87b97b7c8bfe7dcf1b2d41eb (diff)
downloadpostgresql-b8476a09fe83f83050a528bd9ca10d37fdf3a727.tar.gz
postgresql-b8476a09fe83f83050a528bd9ca10d37fdf3a727.zip
From: Andrew Martin <martin@biochemistry.ucl.ac.uk>
psql .psqlrc file startup(Andrew)
-rw-r--r--src/bin/psql/psql.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c
index c1ee52ef160..939ae237797 100644
--- a/src/bin/psql/psql.c
+++ b/src/bin/psql/psql.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.127 1998/01/22 18:50:22 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.128 1998/01/23 19:21:11 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2413,9 +2413,11 @@ main(int argc, char **argv)
char *singleQuery = NULL;
bool listDatabases = 0;
- int successResult = 1;
+ int successResult = 1;
bool singleSlashCmd = 0;
- int c;
+ int c;
+
+ char *home = NULL; /* Used to store $HOME */
MemSet(&settings, 0, sizeof settings);
settings.opt.align = 1;
@@ -2556,6 +2558,30 @@ main(int argc, char **argv)
printf(" type \\g or terminate with semicolon to execute query\n");
printf(" You are currently connected to the database: %s\n\n", dbname);
}
+
+ /*
+ * 20.06.97 ACRM See if we've got a /etc/psqlrc or .psqlrc file
+ */
+ if(!access("/etc/psqlrc",R_OK))
+ HandleSlashCmds(&settings, "\\i /etc/psqlrc", "");
+ if((home = getenv("HOME"))!=NULL) {
+ char *psqlrc = NULL,
+ *line = NULL;
+
+ if((psqlrc = (char *)malloc(strlen(home) + 10))!=NULL) {
+ sprintf(psqlrc, "%s/.psqlrc", home);
+ if(!access(psqlrc, R_OK)) {
+ if((line = (char *)malloc(strlen(psqlrc) + 5))!=NULL) {
+ sprintf(line, "\\i %s", psqlrc);
+ HandleSlashCmds(&settings, line, "");
+ free(line);
+ }
+ }
+ free(psqlrc);
+ }
+ }
+ /* End of check for psqlrc files */
+
if (qfilename || singleSlashCmd)
{