Haugh's "env"

ok at quintus ok at quintus
Fri Jul 15 09:35:45 AEST 1988


"john f. haugh ii" recently sent out public domain code which implements
the System V "env" command.  There are a number of problems:
(1) It uses strchr() rather than index(); if you have an older
    BSD system (why else would you lack "env"?) you probably haven't
    got strchr() either.
(2) main() doesn't end with a call to exit(0); but just falls off the end.
(3) When a command can't be executed, the diagnostic message is
	<command pathname>: <perror text>
    whereas the real "env" command prints
	<perror text>: <command pathname>
    This one's pretty minor.
(4) When a command can't be executed, Haugh's version does _exit(127);
    the status returned by the real env is 1, so change that 127 to 1.
(5) Haugh's version calls
	execve(*argv, argv, env);
    which means that e.g. "env fred=47 sh" doesn't work.  This should be
	extern char **environ;
	environ = env;
	execvp(*argv, argv);
    {Why is there no execvep() library routine?}



More information about the Comp.sources.bugs mailing list