#!/bin/sh
# $Id: noenv,v 1.3 2014/05/10 22:43:32 tom Exp $
# trim the environment to minimal (PATH may still be long...)
env | sed -e 's/=.*//' -e '/^[ 	].*/d' | \
while true
do
	read value
	if test -z "$value" ; then
		# honor assignments to variables in the parameter list
		while test $# != 0
		do
			case "x$1" in
			*=*)
				eval $1
				name=`echo "$1"|sed -e 's/=.*//'`
				export $name
				shift 1
				;;
			*)
				break
				;;
			esac
		done
		exec "$@"
		break
	fi
	case "$value" in
	HOME|PATH|USER|_|SHLVL|TMPDIR|LOGNAME)
		;;
	*\ *|*\(*|*\)*|*\!*)
		#echo "...skipping $value"
		;;
	*)
		#echo value:"$value"
		unset "$value"
		;;
	esac
done
