Don't quote the value of EDITOR on Unix, only on Windows. Per discussion.
authorTom Lane <[email protected]>
Mon, 15 Nov 2004 23:15:12 +0000 (23:15 +0000)
committerTom Lane <[email protected]>
Mon, 15 Nov 2004 23:15:12 +0000 (23:15 +0000)
src/bin/psql/command.c

index 1ee3decfdf627ba4b2067702a134c1dc7952dd29..3504f56ae5b8deb915fc96fb0fcb073c1134b068 100644 (file)
@@ -1096,12 +1096,20 @@ editFile(const char *fname)
        if (!editorName)
                editorName = DEFAULT_EDITOR;
 
+       /*
+        * On Unix the EDITOR value should *not* be quoted, since it might include
+        * switches, eg, EDITOR="pico -t"; it's up to the user to put quotes in it
+        * if necessary.  But this policy is not very workable on Windows, due to
+        * severe brain damage in their command shell plus the fact that standard
+        * program paths include spaces.
+        */
        sys = pg_malloc(strlen(editorName) + strlen(fname) + 10 + 1);
-       sprintf(sys,
 #ifndef WIN32
-                       "exec "
+       sprintf(sys, "exec %s '%s'", editorName, fname);
+#else
+       sprintf(sys, "%s\"%s\" \"%s\"%s",
+                       SYSTEMQUOTE, editorName, fname, SYSTEMQUOTE);
 #endif
-                       "%s\"%s\" \"%s\"%s", SYSTEMQUOTE, editorName, fname, SYSTEMQUOTE);
        result = system(sys);
        if (result == -1)
                psql_error("could not start editor \"%s\"\n", editorName);