Haugh's "env"

Larry Wall lwall at devvax.JPL.NASA.GOV
Fri Jul 15 17:48:13 AEST 1988


In article <168 at quintus.UUCP> ok at 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 at jpl-devvax.jpl.nasa.gov



More information about the Comp.sources.bugs mailing list