|
3 | 3 | *
|
4 | 4 | * Copyright (c) 2000-2004, PostgreSQL Global Development Group
|
5 | 5 | *
|
6 |
| - * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.134 2004/11/09 14:39:43 petere Exp $ |
| 6 | + * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.135 2004/11/15 23:15:12 tgl Exp $ |
7 | 7 | */
|
8 | 8 | #include "postgres_fe.h"
|
9 | 9 | #include "command.h"
|
@@ -1096,12 +1096,20 @@ editFile(const char *fname)
|
1096 | 1096 | if (!editorName)
|
1097 | 1097 | editorName = DEFAULT_EDITOR;
|
1098 | 1098 |
|
| 1099 | + /* |
| 1100 | + * On Unix the EDITOR value should *not* be quoted, since it might include |
| 1101 | + * switches, eg, EDITOR="pico -t"; it's up to the user to put quotes in it |
| 1102 | + * if necessary. But this policy is not very workable on Windows, due to |
| 1103 | + * severe brain damage in their command shell plus the fact that standard |
| 1104 | + * program paths include spaces. |
| 1105 | + */ |
1099 | 1106 | sys = pg_malloc(strlen(editorName) + strlen(fname) + 10 + 1);
|
1100 |
| - sprintf(sys, |
1101 | 1107 | #ifndef WIN32
|
1102 |
| - "exec " |
| 1108 | + sprintf(sys, "exec %s '%s'", editorName, fname); |
| 1109 | +#else |
| 1110 | + sprintf(sys, "%s\"%s\" \"%s\"%s", |
| 1111 | + SYSTEMQUOTE, editorName, fname, SYSTEMQUOTE); |
1103 | 1112 | #endif
|
1104 |
| - "%s\"%s\" \"%s\"%s", SYSTEMQUOTE, editorName, fname, SYSTEMQUOTE); |
1105 | 1113 | result = system(sys);
|
1106 | 1114 | if (result == -1)
|
1107 | 1115 | psql_error("could not start editor \"%s\"\n", editorName);
|
|
0 commit comments