From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] report which $PATH entry had trouble running execvp(3)
Date: Wed, 20 Apr 2011 17:00:17 -0700 [thread overview]
Message-ID: <7v1v0w1nji.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: 20110420055111.GB28597@sigill.intra.peff.net
Jeff King <peff@peff.net> writes:
> On Tue, Apr 19, 2011 at 09:01:21PM -0700, Junio C Hamano wrote:
>
>> You can add your own custom subcommand 'frotz' to the system by adding
>> 'git-frotz' in a directory somewhere in your $PATH environment variable.
>> When you ask "git frotz" from the command line, "git-frotz" is run via
>> execvp(3).
>> [...]
>> we do not report 'git-frotz' in which directory we had trouble with.
>> We could do better if we implemented the command search behaviour of
>> execvp(3) ourselves.
>
> I like the idea of giving the user more information about which
> git-frotz was the problem. Usually there is just one, and pointing them
> to it saves them time.
>
> But what about the case of
>
> mkdir one two
> touch one/frotz two/frotz
> PATH=one:two:$PATH
>
> We would report two/frotz, but might it be even better to say "we found
> 2 frotzes, but neither of them were executable"?
No, one/frotz is the first one found along $PATH, and we report that we
cannot exec 'one/frotz'. We are trying to imitate the semantics of the
usual command search done by execvp() and by the shell. Three possible
user reactions are (1) Huh? I wanted to see two/frotz be used. My $PATH
is wrong, and I'll fix it by reordering elements on $PATH; (2) Huh? I
wanted to see two/frotz be used. I have a stale one in one/frotz, and I'll
fix it by removing it; and (3) Yuck, I forgot to chmod +x one/frotz.
As J6t mentioned, the user needs to examine what went wrong anyway. The
point of the change is to make it easier by giving more information than
what execvp(3) gives us (especially there may be hidden GIT_EXEC_PATH that
the user of a third-party scripted Porcelain may not be aware of, which is
tacked before the usual $PATH).
>> Three plausible scenarios that the execvp(3) would fail for us are:
>>
>> * The first 'git-frotz' found in a directory on $PATH was not a proper
>> executable binary, and we got "Exec format error" (ENOEXEC);
>
> What about the magic "unknown things get executed as shell scripts"
> behavior that is implemented by libc's execvp?
> ...
> I have always found that behavior slightly insane, but it is
> well-established, and your sane_execvp breaks anybody who is depending
> on it.
We can choose to add that on top of the sane_execvp() patch.
next prev parent reply other threads:[~2011-04-21 0:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-18 20:54 [REGRESSION] git-wrapper to run-commands codepath regression Junio C Hamano
2011-04-18 21:11 ` Jeff King
2011-04-18 21:18 ` Jeff King
2011-04-18 21:40 ` Junio C Hamano
2011-04-18 21:43 ` Jeff King
2011-04-18 22:10 ` Junio C Hamano
2011-04-18 22:11 ` Andreas Schwab
2011-04-18 21:16 ` Junio C Hamano
2011-04-18 22:17 ` Jonathan Nieder
2011-04-19 7:05 ` [PATCH] run-command: write full error message in die_child Jonathan Nieder
2011-04-20 7:42 ` Johannes Sixt
2011-04-20 10:33 ` [PATCH v2 0/2] " Jonathan Nieder
2011-04-20 10:35 ` [PATCH 1/2] tests: check error message from run_command Jonathan Nieder
2011-04-20 10:40 ` [PATCH 2/2] run-command: handle short writes and EINTR in die_child Jonathan Nieder
2011-04-19 0:07 ` [REGRESSION] git-wrapper to run-commands codepath regression Junio C Hamano
2011-04-20 4:01 ` [PATCH] report which $PATH entry had trouble running execvp(3) Junio C Hamano
2011-04-20 5:51 ` Jeff King
2011-04-21 0:00 ` Junio C Hamano [this message]
2011-04-20 7:37 ` Johannes Sixt
2011-04-20 11:21 ` Jonathan Nieder
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=7v1v0w1nji.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).