git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] help.c: don't blame an user's typo when the system is at fault

From
Thomas Rast <trast@student.ethz.ch>
Date
Jul 20, 2009, 14:17 UTC
Message-ID
<200907201617.48168.trast@student.ethz.ch>
In-Reply-To
<200907201545.06030.barra_cuda@katamail.com>
Michele Ballabio wrote:
> Is the call to strerror() useless anyway?
[...]
> +	if (!strcmp(cmd, main_cmds.names[0]->name))
> +		die("Failed to run command '%s': %s\n",
> +			cmd, strerror(errno));
The invocation of help_unknown_cmd comes from
	while (1) {
		// ...
		was_alias = run_argv(&argc, &argv);
		if (errno != ENOENT)
			break;
		// ... side branch with an exit() ...
		if (!done_help) {
			cmd = argv[0] = help_unknown_cmd(cmd);

so errno is always ENOENT when help_unknown_cmd() is called. (Furthermore, the function itself uses git_config() and load_command_list(), both of which _probably_ clobber errno, I don't really have the time for an in-depth check.)

It also seems that the 'errno != ENOENT' check was intended to catch the case where the command failed for any reason other than that it does not exist, but this collides with the kernel reporting ENOENT if the _interpreter_ does not exist. Perhaps run_argv should differentiate the case where a command executable exists but cannot be run?

[I started writing a reply because I wanted to ask for a conversion to die_errno() in the spirit of d824cbb (Convert existing die(..., strerror(errno)) to die_errno(), 2009-06-27). Please keep that in mind if you put in another die() that mentions errno.]

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Previous: Michele BallabioNext: Jeff King
Message 3 of 4 in “Bad DWIM response when git gui cannot start”
  1. Peter KreftingJul 20, 2009
  2. help.c: don't blame an user's typo when the system is at faultMichele Ballabio, Jul 20, 2009
  3. Thomas RastJul 20, 2009
  4. Jeff KingJul 20, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.