Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!elroy!devvax!lwall
From: lwall@devvax.JPL.NASA.GOV (Larry Wall)
Newsgroups: comp.sources.bugs
Subject: Re: Haugh's "env"
Message-ID: <2457@devvax.JPL.NASA.GOV>
Date: 15 Jul 88 07:48:13 GMT
References: <168@quintus.UUCP>
Reply-To: lwall@devvax.JPL.NASA.GOV (Larry Wall)
Organization: Jet Propulsion Laboratory, Pasadena, CA.
Lines: 30

In article <168@quintus.UUCP> ok@quintus () writes:
: "john f. haugh ii" recently sent out public domain code which implements
: the System V "env" command...

Just for the fun of it, I whipped one off in perl (discovering one perl bug
in the process--this needs patch 9 for reset 'E' to wipe the environment).

Here's env a la perl:

#!/usr/bin/perl

reset 'E', shift if $ARGV[0] eq '-';

$ENV{$1} = $2, shift while $ARGV[0] =~ /(\w+)=(.*)/;

if ($#ARGV < 0) {
    foreach $key (sort keys(ENV)) {
	print $key,'=',$ENV{$key},"\n";
    }
}
else {
    exec @ARGV;
    print $!,': ',shift,"\n";
    exit 1;
}

The only difference I can see is that it sorts the environment variables
when it prints them out.

Larry Wall
lwall@jpl-devvax.jpl.nasa.gov