mirror of
				git://git.code.sf.net/p/cdesktopenv/code
				synced 2025-03-09 15:50:02 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			66 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			66 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
| #! /usr/bin/ksh
 | |
| # shell version of env command
 | |
| case $(getopts '[-]' opt '--???man' 2>&1) in
 | |
| version=[0-9]*)
 | |
|     usage=$'[-?@(#)env (AT&T Labs Research) 1999-05-20\n]
 | |
|         [-author?David Korn <dgkorn@gmail.com>]
 | |
|         [-license?http://www.research.att.com/sw/tools/reuse]
 | |
|         [+NAME?env - set environment for command invocation]
 | |
|         [+DESCRIPTION?\benv\b modifies the current environment according
 | |
| 		to the \aname\a\b=\b\avalue\a arguments, and then
 | |
| 		invokes \acommand\a with the modified environment.]
 | |
| 	[+?If \acommand\a is not specified, the resulting environment
 | |
| 		is written to standard output quoted as required for
 | |
| 		reading by the \bsh\b.]
 | |
| 	[i:ignore-environment?Invoke \acommand\a with the exact environment
 | |
| 		specified by the \aname\a\b=\b\avalue\a arguments; inherited
 | |
| 		environment variables are ignored.  As an obsolete feature,
 | |
| 		\b-\b by itself can be specified instead of \b-i\b.]
 | |
| 	[u:unset]:[name?Unset the environment variable \aname\a if it was
 | |
| 		in the environment.  This option can be repeated to unset
 | |
| 		additional variables.]
 | |
| 
 | |
| 	[name=value]... [command ...]
 | |
| 
 | |
| 	[+EXIT STATUS?If \acommand\a is invoked, the exit status of \benv\b
 | |
| 		will be that of \acommand\a.  Otherwise, it will be one of
 | |
| 		the following:]{
 | |
| 	        [+0?\benv\b completed successfully.]
 | |
| 	        [+126?\acommand\a was found but could not be invoked.]
 | |
| 	        [+127?\acommand\a could not be found.]
 | |
| 	}
 | |
|         [+SEE ALSO?\bsh\b(1), \bexport\b(1)]
 | |
|     '
 | |
|     ;;
 | |
| *)
 | |
|     usage='iu:[name] [name=value]... [command ...]'
 | |
|     ;;
 | |
| esac
 | |
| clear=
 | |
| while	getopts  "$usage" var
 | |
| do	case $var in
 | |
| 	i)	clear=1;;
 | |
| 	u)	command unset $OPTARG 2> /dev/null;;
 | |
| 	esac
 | |
| done
 | |
| #[[ $var == "" ]] || exit 1
 | |
| shift $((OPTIND-1))
 | |
| if	[[ $1 == - ]]  # obsolete form
 | |
| then	clear=1
 | |
| 	shift
 | |
| fi
 | |
| if	[[ $clear == 1 ]]
 | |
| then	typeset +x $(typeset +x)
 | |
| fi
 | |
| while	true
 | |
| do	case $1 in
 | |
| 	*=*)	export "$1";;
 | |
| 	*) break;;
 | |
| 	esac
 | |
| 	shift
 | |
| done
 | |
| if	(( $# >0 ))
 | |
| then	exec "$@"
 | |
| else	export
 | |
| 	exit 0
 | |
| fi
 |