PSQLRC environment variable. - Mailing list pgsql-patches

From James Tanis
Subject PSQLRC environment variable.
Date
Msg-id 200403081922.i28JMJcL031317@saint.sysdetect.com
Whole thread Raw
Responses Re: PSQLRC environment variable.  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: PSQLRC environment variable.  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-patches
In the tradition of telnet, xinit, and others, I've created a patch which
allows users to override the location of .psqlrc by setting the PSQLRC
environment variable. I occurs to me that you have probably considered this
and the fact that it is not implemented suggests that you have rejected the
idea, but I needed it and I figured it couldn't hurt to pass it along.

PSQLRC overrides $HOME/.psqlrc and, as with $HOME/.psqlrc, if there is an
error accessing the file, the function just returns having done nothing.

Cheers,
/jtt
jtt@sysd.com


     ----------------------------------------------------------------
Index: startup.c
===================================================================
RCS file: /src/cvs/postgres/src/bin/psql/startup.c,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 startup.c
--- startup.c    16 Dec 2003 22:15:32 -0000    1.1.1.4
+++ startup.c    7 Mar 2004 15:15:54 -0000
@@ -561,7 +561,12 @@
 #ifdef WIN32
 #define R_OK 0
 #endif
-
+    if ((psqlrc = getenv("PSQLRC")))
+    {
+      if (access(psqlrc, R_OK) == 0)
+        process_file(psqlrc);
+      return;
+    }
     /* Look for one in the home dir */
     home = getenv("HOME");


pgsql-patches by date:

Previous
From: evanm@frap.net
Date:
Subject: initdb could use some lower default settings (trivial patch)
Next
From: Fabien COELHO
Date:
Subject: Re: notice about costly ri checks (2)