#!/usr/local/bin/perl -w eval 'exec /usr/local/bin/perl -w -S $0 ${1+"$@"}' if 0; # not running under some shell # Perl version of the env command. # Matthew Bafford # 2/28/1999 use strict; while ( @ARGV && $ARGV[0] =~ /^-/ ) { my $arg = shift; if ( $arg eq '-i' ) { delete $ENV{$_} for keys %ENV; } elsif ( $arg =~ /^-u(.*)/ ) { delete $ENV{ length($1) ? $1 : shift }; } else { print "$0: invalid option -- $arg\n"; exit 2; } } while ( @ARGV && $ARGV[0] =~ /=/ ) { my ( $name, $value ) = split /=/, shift, 2; $ENV{$name} = $value; } if ( !@ARGV ) { for ( keys %ENV ) { print "$_=$ENV{$_}\n"; } exit 0; } exec(shift, @ARGV) or exit 127; __END__ =pod =head1 NAME env - Run a program in a modified environment. =head1 SYNOPSIS env [B<-i>] [B<-u> name]... [name=value]... [command [args]...] =head1 DESCRIPTION I runs a command with the environment modified as specified by the command line. If no command is specified, I prints out the modified environment. =head2 OPTIONS I accepts the following options: =over 4 =item B<-i> Clears the environment, passing only the values specifed to the command. =item B<-u> I Clears the environment variable I if it exists. =back =head1 ENVIRONMENT The working of I is not influenced by any environment variables. =head1 DIAGNOSTICS If the command is invoked, the exit status of I will be the exit status of the command. Otherwise, I will return one of the following values: 0 env completed successfully. 1-125 An error occured in env. 127 There was an error running the command specified. =head1 BUGS I has no known bugs. =head1 AUTHOR This Perl version of I was written by Matthew Bafford, I. =head1 COPYRIGHT and LICENSE This program is copyright (c) Matthew Bafford 1999. This program is free and open software. You may use, modify, distribute, and sell this program (and any modified variants) in any way you wish, provided you do not restrict others from doing the same.