>
>
> OK, here's a quick patch to psql.c which first reads commands from
> /etc/psqlrc and then from $HOME/.psqlrc
>
> I've used access() to check on the existence of these files; I'm
> not sure if every system has access(), so it might be necessary
> to change to stat() instead. Certainly Linux and Irix *do* have
> access()
Can I request we search in the postgres install directory first, then
the home directory, or is that stupid because there may not be a
postgresql install directory on the machine you are running psql on.
Just asking.
>
> Andrew
>
>
> *** src/bin/psql/psql.c.orig Fri Jun 20 21:54:31 1997
> --- src/bin/psql/psql.c Fri Jun 20 22:23:49 1997
> ***************
> *** 1598,1603 ****
> --- 1598,1605 ----
> bool singleSlashCmd = 0;
> int c;
>
> + char *home = NULL; /* Used to store $HOME */
> +
> memset(&settings, 0, sizeof settings);
> settings.opt.align = 1;
> settings.opt.header = 1;
> ***************
> *** 1728,1733 ****
> --- 1730,1760 ----
> 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) {
> /*
> * read in a file full of queries instead of reading in queries
>
> ----------------------------------------------------------------------------
> Dr. Andrew C.R. Martin University College London
> EMAIL: (Work) martin@biochem.ucl.ac.uk (Home) andrew@stagleys.demon.co.uk
> URL: http://www.biochem.ucl.ac.uk/~martin
> Tel: (Work) +44(0)171 419 3890 (Home) +44(0)1372 275775
>
>
- --
Bruce Momjian
maillist@candle.pha.pa.us
------------------------------