Re: [PATCH] Make git send-email accept $EDITOR with arguments
- From
- Luciano Rocha <luciano@eurotux.com>
- Date
- Dec 20, 2007, 20:32 UTC
- Message-ID
- <20071220203211.GA12296@bit.office.eurotux.com>
- In-Reply-To
- <1198181646-28632-1-git-send-email-hendeby@isy.liu.se>
On Thu, Dec 20, 2007 at 09:14:06PM +0100, Gustaf Hendeby wrote: <snip>
Show 19 quoted lines
> I'm not completely satisfied with the problem with embedded spaces,
> but my Perl skills aren't good enough to do anything about it. If
> anyone have any suggestions on how to do it, it would be greatly
> appreciated. None-the-less, even with this shortcoming, I think this
> is a step in the right direction.
>
> git-send-email.perl | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/git-send-email.perl b/git-send-email.perl
> index 248d035..47ae77c 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -400,7 +400,7 @@ EOT
> close(C);
>
> my $editor = $ENV{GIT_EDITOR} || $repo->config("core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
> - system($editor, $compose_filename);
> + system((split ' ', $editor), $compose_filename);That should be enough. Use system("$editor $compose_filename") to use perl's implicit split or, in case of meta-characters in the string, external sh -c.
Or always use the shell: $shell = $ENV{SHELL} || "/bin/sh"; system($shell, "-c", "$editor $compose_filename");
BTW, maybe add a check for the return code? system(...) == 0 or die "editor failed\n";
-- Luciano Rocha <luciano@eurotux.com> Eurotux Informática, S.A. <http://www.eurotux.com/>