From: Gustaf Hendeby <hidden> Date: 2016-06-15 22:44:00
Currently git send-email does not accept $EDITOR with arguments, eg,
emacs -nw, when starting an editor to produce a cover letter. This fixes
this in the simplest way possible, assume all spaces separates either
the command from the first argument, or two arguments. This should
work in most cases, but will break with quoted strings embedded spaces.
An example of a problematic case is when there is a space in the path
to the command.
Signed-off-by: Gustaf Hendeby <redacted>
---
This is related to the problems recently observed in the built in git
commit and git tag. I guess the behavior of git send-email has been
the same from the start, but having it treat $EDITOR substantially
different from that of git commit and git tag seems like bug or at
least something that should be avoided.
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(-)
On Thu, Dec 20, 2007 at 09:14:06PM +0100, Gustaf Hendeby wrote:
<snip>
quoted hunk
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(-)
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 [off-list ref]
Eurotux Informática, S.A. <http://www.eurotux.com/>
From: Gustaf Hendeby <hidden> Date: 2016-06-15 22:44:01
Currently git send-email does not accept $EDITOR with arguments, eg,
emacs -nw, when starting an editor to produce a cover letter. This
fix uses perl's implicit splitting to perform the task and that should
hopefully cover most interesting cases.
Signed-off-by: Gustaf Hendeby <redacted>
---
Thanks to Luciano for the tip to use the internal splitting in perl,
that should be a better solution than to split on all spaces. I don't
think it is necessary, though, to add an extra error message if the
system call fails, system in it self already produces something that
should be clear enough. If anyone got a strong oppinion for another
error message I'll fix that.
Junio, even if this is technically not a bug fix, it would be nice to
get this fix into the 1.5.4 so that the usage of $EDITOR becomes more
consistent throughout git.
/Gustaf
git-send-email.perl | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
If you are going to do it that way, I suspect you want to quotemeta
$compose_filename.
-Peff
Generally that would be true, but is that really necessary when I know
$compose_filename is defined as:
my $compose_filename = ".msg.$$";
Or, should I take it that you prefer the version using split? I didn't
really feel good about the possibility of splitting paths with spaces
that came with that one though.
/Gustaf
From: Jeff King <hidden> Date: 2016-06-15 22:44:01
On Fri, Dec 21, 2007 at 04:23:11PM +0100, Gustaf Hendeby wrote:
quoted
If you are going to do it that way, I suspect you want to quotemeta
$compose_filename.
Generally that would be true, but is that really necessary when I know
$compose_filename is defined as:
my $compose_filename = ".msg.$$";
I know; it is just easier to see that it is correct with the quotemeta
(and correct in the face of somebody changing the message later).
Or, should I take it that you prefer the version using split? I didn't
really feel good about the possibility of splitting paths with spaces
that came with that one though.
I am fine with using the shell. Though keep in mind that the two
solutions will behave differently with
EDITOR='foo; bar'
That is, system("$editor $message") will actually invoke the shell,
whereas system(split(/ /, $editor), $message) will _just_ split on
whitespace. We should do whatever is consistent with the rest of the git
commands (off the top of my head, I don't know).
-Peff
From: Gustaf Hendeby <hidden> Date: 2016-06-15 22:44:01
On 2007-12-21 20:23, Jeff King wrote:
On Fri, Dec 21, 2007 at 04:23:11PM +0100, Gustaf Hendeby wrote:
quoted
quoted
If you are going to do it that way, I suspect you want to quotemeta
$compose_filename.
Generally that would be true, but is that really necessary when I know
$compose_filename is defined as:
my $compose_filename = ".msg.$$";
I know; it is just easier to see that it is correct with the quotemeta
(and correct in the face of somebody changing the message later).
Point taken!
quoted
Or, should I take it that you prefer the version using split? I didn't
really feel good about the possibility of splitting paths with spaces
that came with that one though.
I am fine with using the shell. Though keep in mind that the two
solutions will behave differently with
EDITOR='foo; bar'
That is, system("$editor $message") will actually invoke the shell,
whereas system(split(/ /, $editor), $message) will _just_ split on
whitespace. We should do whatever is consistent with the rest of the git
commands (off the top of my head, I don't know).
A quick look at the proposed solution to the similar problem with git
commit, using code now in git tag, it seems it uses a split like
solution, though taking " and ' quoting into consideration. On the top
of my head I can't come up with any other commands using $EDITOR. I'll
try to find some time the next couple of days to make a reasonable
equivalent solution here.
Thanks,
Gustaf