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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]