Current-Users archive

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

Question regarding utility exit status

During a recent IRC session, I noticed that ls(1), what(1), stat(1), and rm(1) (and, witwh maya's recent commit, ldd(1)) are all in the camp:

	If ANY of the files listed on the command line results in an
	error, then the utility exits with EXIT_FAILURE;  exit with
	EXIT_SUCCESS only if ALL of the listed files succeed.

On the other hand, stat(1) and file(1) are in a different camp:

	If ALL of the files listed on the command line result in an
	error, then exit with EXIT_FAILURE; exit with EXIT_SUCCESS
	if ANY of the files succeeds.

(I feel fairly certain that there are additional members in both camps, but I was too lazy to conduct a complete audit.)

My question is, which of these behaviors is correct? Wouldn't it make sense for all (or at least, most) utilities to be in the same camp? Does POSIX take any particular view on this? (And does POSIX take different views for different utilities?)

I suspect it's probably fairly uncommon (but _not_ rare) for one to invoke these utilities with multiple "targets" and then tests the exit status. But IMHO we should have predictable behavior.

| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:          |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |

Home | Main Index | Thread Index | Old Index