From: Tom Lane Date: Mon, 15 Nov 2004 23:15:12 +0000 (+0000) Subject: Don't quote the value of EDITOR on Unix, only on Windows. Per discussion. X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=fd6adccd335124d79a4009940832b56fe8165408;p=users%2Fbernd%2Fpostgres.git Don't quote the value of EDITOR on Unix, only on Windows. Per discussion. --- diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 1ee3decfdf..3504f56ae5 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -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);