From: Duncan Roe <duncan_roe@acslink.net.au>
To: git <git@vger.kernel.org>
Subject: [BUG] [PATCH]: run-command.c
Date: Fri, 21 Oct 2016 16:50:13 +1100 [thread overview]
Message-ID: <20161021055013.GA31554@dimstar.local.net> (raw)
prepare_shell_cmd() executes /bin/sh with superfluous arguments on all but
single-word shell commands.
For example, if .git/config has this alias (the sleep is to leave time to
examine output from ps, &c.):
[alias]
tryme = "!echo $PWD;sleep 600"
running "git tryme" in one console and checking what it does in another
--- 1st xterm
16:42:12$ git tryme
/usr/src/git/.git
echo $PWD;sleep 600: line 1: 2602 Terminated sleep 600
16:43:15$
--- 2nd xterm
16:42:06$ ps axf|grep -A2 trym[e]
2599 pts/4 S+ 0:00 \_ git tryme
2601 pts/4 S+ 0:00 \_ /bin/sh -c echo $PWD;sleep 600 echo $PWD;sleep 600
2602 pts/4 S+ 0:00 \_ sleep 600
16:42:45$ cat /proc/2601/cmdline | xargs -0 -n1 echo
/bin/sh
-c
echo $PWD;sleep 600
echo $PWD;sleep 600
16:43:04$ kill 2602
16:43:15$
---
There is an extra "-c" argument. This is caused by a missing "else", fixed by
the appended patch,
Cheers ... Duncan.
----------8<-------------------
--- a/run-command.c
+++ b/run-command.c
@@ -182,8 +182,8 @@ static const char **prepare_shell_cmd(struct argv_array *out, const char **argv)
else
argv_array_pushf(out, "%s \"$@\"", argv[0]);
}
-
- argv_array_pushv(out, argv);
+ else
+ argv_array_pushv(out, argv);
return out->argv;
}
next reply other threads:[~2016-10-21 6:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-21 5:50 Duncan Roe [this message]
2016-10-21 9:00 ` [BUG] [PATCH]: run-command.c Jeff King
2016-10-21 11:07 ` Duncan Roe
2016-10-21 17:19 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161021055013.GA31554@dimstar.local.net \
--to=duncan_roe@acslink.net.au \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.