|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * 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 $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -2413,9 +2413,11 @@ main(int argc, char **argv)
|
2413 | 2413 | char *singleQuery = NULL;
|
2414 | 2414 |
|
2415 | 2415 | bool listDatabases = 0;
|
2416 |
| - int successResult = 1; |
| 2416 | + int successResult = 1; |
2417 | 2417 | bool singleSlashCmd = 0;
|
2418 |
| - int c; |
| 2418 | + int c; |
| 2419 | + |
| 2420 | + char *home = NULL; /* Used to store $HOME */ |
2419 | 2421 |
|
2420 | 2422 | MemSet(&settings, 0, sizeof settings);
|
2421 | 2423 | settings.opt.align = 1;
|
@@ -2556,6 +2558,30 @@ main(int argc, char **argv)
|
2556 | 2558 | printf(" type \\g or terminate with semicolon to execute query\n");
|
2557 | 2559 | printf(" You are currently connected to the database: %s\n\n", dbname);
|
2558 | 2560 | }
|
| 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 | + |
2559 | 2585 | if (qfilename || singleSlashCmd)
|
2560 | 2586 | {
|
2561 | 2587 |
|
|
0 commit comments