--- src/bin/psql/startup.c	Sat Oct 19 02:05:36 2002
+++ src/bin/psql/startup.c	Mon Jan  6 20:16:30 2003
@@ -42,7 +42,7 @@
  */
 PsqlSettings pset;
 
-#define PSQLRC ".psqlrc"
+#define PSQLRC ".desk/psqlrc"
 
 /*
  * Structures to pass information between the option parsing routine
@@ -83,6 +83,7 @@
 			printSSLInfo(void);
 #endif
 
+char *DecoreBeg, *DecoreEnd;
 
 /*
  *
@@ -99,6 +100,8 @@
 	char	   *password = NULL;
 	bool		need_pass;
 
+	DecoreBeg = NULL;
+	DecoreEnd = NULL;
 	setlocale(LC_ALL, "");
 #ifdef ENABLE_NLS
 	bindtextdomain("psql", LOCALEDIR);
@@ -231,7 +234,7 @@
 	 */
 
 	/*
-	 * process file given by -f
+	 * process file given by -f or -Q
 	 */
 	if (options.action == ACT_FILE && strcmp(options.action_string, "-") != 0)
 	{
@@ -364,19 +367,19 @@
 	extern char *optarg;
 	extern int	optind;
 	int			c;
-	bool		used_old_u_option = false;
+	bool		used_old_u_option = false, sqlbang = false;
 
 	memset(options, 0, sizeof *options);
 
 #ifdef HAVE_GETOPT_LONG
-	while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:h:Hlno:p:P:qR:sStT:uU:v:VWxX?", long_options, &optindex)) != -1)
+	while ((c = getopt_long(argc, argv, "aAc:d:D:eEf:F:h:Hlno:p:P:qQ:R:sStT:uU:v:VWxX?", long_options, &optindex)) != -1)
 #else							/* not HAVE_GETOPT_LONG */
 
 	/*
 	 * Be sure to leave the '-' in here, so we can catch accidental long
 	 * options.
 	 */
-	while ((c = getopt(argc, argv, "aAc:d:eEf:F:h:Hlno:p:P:qR:sStT:uU:v:VWxX?-")) != -1)
+	while ((c = getopt(argc, argv, "aAc:d:D:eEf:F:h:Hlno:p:P:qQ:R:sStT:uU:v:VWxX?-")) != -1)
 #endif   /* not HAVE_GETOPT_LONG */
 	{
 		switch (c)
@@ -400,6 +403,10 @@
 			case 'd':
 				options->dbname = optarg;
 				break;
+			case 'D':
+				if  (DecoreBeg) DecoreEnd = optarg;
+				else DecoreBeg = optarg;
+				break;
 			case 'e':
 				SetVariable(pset.vars, "ECHO", "queries");
 				break;
@@ -459,6 +466,12 @@
 			case 'q':
 				SetVariableBool(pset.vars, "QUIET");
 				break;
+			case 'Q':
+				SetVariableBool(pset.vars, "ON_ERROR_STOP");
+				options->action = ACT_FILE;
+				options->action_string = optarg;
+				sqlbang = true;
+				break;
 			case 'R':
 				pset.popt.topt.recordSep = xstrdup(optarg);
 				break;
@@ -563,21 +576,45 @@
 		}
 	}
 
-	/*
-	 * if we still have arguments, use it as the database name and
-	 * username
-	 */
-	while (argc - optind >= 1)
+	if (sqlbang)
+	{
+		char optname[] = "1";
+		while (argc - optind >= 1)
+		{
+			if (optname[0] <= '9')
+			{
+				if (!SetVariable(pset.vars, optname, argv[optind]))
+				{
+					fprintf(stderr, "%s: could not set variable %s\n",
+							pset.progname, optname);
+					exit(EXIT_FAILURE);
+				}
+			}
+			else if (!QUIET())
+				fprintf(stderr, "%s: warning: extra option %s ignored\n",
+						pset.progname, argv[optind]);
+			optname[0]++;
+			optind++;
+		}
+	}
+	else
 	{
-		if (!options->dbname)
-			options->dbname = argv[optind];
-		else if (!options->username)
-			options->username = argv[optind];
-		else if (!QUIET())
-			fprintf(stderr, gettext("%s: warning: extra option %s ignored\n"),
-					pset.progname, argv[optind]);
+		/*
+		 * if we still have arguments, use it as the database name and
+		 * username
+		 */
+		while (argc - optind >= 1)
+		{
+			if (!options->dbname)
+				options->dbname = argv[optind];
+			else if (!options->username)
+				options->username = argv[optind];
+			else if (!QUIET())
+				fprintf(stderr, gettext("%s: warning: extra option %s ignored\n"),
+						pset.progname, argv[optind]);
 
-		optind++;
+			optind++;
+		}
 	}
 
 	if (used_old_u_option && !QUIET())
@@ -588,7 +625,7 @@
 
 
 /*
- * Load .psqlrc file, if found.
+ * Load .desk/psqlrc file, if found.
  */
 static void
 process_psqlrc(void)