tholm@uvicctr.UUCP (Terrence W. Holm) (08/26/88)
EFTH MINIX report #34 - August 1988 - env(1)
There follows an implementation of env(1) for Minix.
Please consider this public domain software.
A "man" page is included.
----------------------------------------------------------
echo x - env.1
gres '^X' '' > env.1 << '/'
XCOMMANDS
X env(1) - set up the environment
X
XINVOCATION
X env [ - ] [ name=defn ] ... [ command ]
X
XEXPLANATION
X Env(1) sets up the environment for the execution
X of <command>, it is often used during testing. The
X option "-" clears out the current environment, new
X entries are added using "name=defn". If no <command>
X string is given then env(1) simply displays the
X environment.
X
XREFERENCES
X printenv(1)
/
echo x - env.c
gres '^X' '' > env.c << '/'
X/* env(1)
X *
X * Author: Terrence Holm Aug. 1988
X *
X *
X * Sets up the environment for testing commands.
X *
X * env [ - ] [ name=defn ] ... [ command ]
X */
X
X#include <stdio.h>
X
Xextern char **environ;
X
X
Xmain( argc, argv )
X int argc;
X char *argv[];
X
X {
X int i;
X char *empty_environ = NULL;
X char **p;
X
X for ( i = 1; i < argc; ++i )
X {
X if ( strcmp( argv[i], "-" ) == 0 )
X environ = &empty_environ;
X
X else if ( strchr( argv[i], '=' ) != NULL )
X putenv( argv[i] );
X
X else /* a command */
X {
X execvp( argv[i], &argv[i] );
X perror( argv[i] );
X exit( 127 );
X }
X }
X
X /* No command given, just print out the environment */
X
X for ( p = environ; *p != NULL; ++p )
X printf( "%s\n", *p );
X
X exit( 0 );
X }
/
----------------------------------------------------------
Edwin L. Froese
uw-beaver!ubc-cs!mprg!handel!froese
Terrence W. Holm
uw-beaver!uvicctr!tholm