diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index 61c7f11..5eae2c5 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -569,6 +569,7 @@ process_psqlrc(char *argv0)
 	char		rc_file[MAXPGPATH];
 	char		my_exec_path[MAXPGPATH];
 	char		etc_path[MAXPGPATH];
+	char	   *env_rc_file;
 
 	find_my_exec(argv0, my_exec_path);
 	get_etc_path(my_exec_path, etc_path);
@@ -576,7 +577,12 @@ process_psqlrc(char *argv0)
 	snprintf(rc_file, MAXPGPATH, "%s/%s", etc_path, SYSPSQLRC);
 	process_psqlrc_file(rc_file);
 
-	if (get_home_path(home))
+	env_rc_file = getenv("PSQLRC");
+	if (env_rc_file)
+	{
+		process_psqlrc_file(env_rc_file);
+	}
+	else if (get_home_path(home))
 	{
 		snprintf(rc_file, MAXPGPATH, "%s/%s", home, PSQLRC);
 		process_psqlrc_file(rc_file);
