Skip to content

Commit

Permalink
Handle more shell metacharacters in editor names
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jonathan Nieder authored and Junio C Hamano committed Oct 31, 2009
1 parent cd0f8e6 commit eab58f1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
const char *args[6];
struct strbuf arg0 = STRBUF_INIT;

if (strcspn(editor, "$ \t'") != len) {
if (strcspn(editor, "|&;<>()$`\\\"' \t\n*?[#~=%") != len) {
/* there are specials */
strbuf_addf(&arg0, "%s \"$@\"", editor);
args[i++] = "sh";
Expand Down

0 comments on commit eab58f1

Please sign in to comment.