@matheusbsbs / matheus-bagliano / commits / eab58f1e8e
Fork 0

Handle more shell metacharacters in editor names

Pass the editor name to the shell if it contains any susv3 shell special character (globs, redirections, variable substitutions, escapes, etc). This way, the meaning of some characters will not meaninglessly change when others are added, and git commands implemented in C and in shell scripts will interpret editor names in the same way. This does not make the GIT_EDITOR setting any more expressive, since one could always use single quotes to force the editor to be passed to the shell. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Oct 30, 2009 at 20:24 UTC eab58f1e8e5ef86b5075ce6dfcd6d3f1b3b888b3
1 file changed +1 -1
editor.c
+1 -1
@@ -28,7 +28,7 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
28 const char *args[6];
29 struct strbuf arg0 = STRBUF_INIT;
30
31 - if (strcspn(editor, "$ \t'") != len) {
31 + if (strcspn(editor, "|&;<>()$`\\\"' \t\n*?[#~=%") != len) {
32 /* there are specials */
33 strbuf_addf(&arg0, "%s \"$@\"", editor);
34 args[i++] = "sh";