Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Startup-file patch and some tcsh emulations



On Sep 30, 12:32pm, Geoff Wing wrote:
> Subject: Startup-file patch and some tcsh emulations
> Heyla,
>   just a small patch to provide some emulations for csh/tcsh functions:
>   glob, printenv, setenv, unsetenv, and a sample filetest

What's wrong with:

	alias glob='print -N'

??

> *** Functions/unsetenv.~1~	Mon Sep 30 12:01:27 1996
> --- Functions/unsetenv	Mon Sep 30 12:00:21 1996
> ***************
> *** 0 ****
> --- 1,11 ----
> + #! /usr/local/bin/zsh
> + if [ $# -eq 0 ]
> + then
> + 	echo "unsetenv: Too few arguments."
> + else
> + 	repeat $#
> + 	do
> + 		unset $1
> + 		shift
> + 	done
> + fi

I usually use `typeset +x' rather than `unset' for unsetenv because in
{t}csh the environment and non-environment settings are independent;
you can have `set FOO=bar' and `setenv FOO blat', and if in that case
you do `unsetenv FOO; echo $FOO' you will still get "bar".  On the
argument that `unsetenv FOO' shouldn't do anything surprising if FOO
was never exported in the first place, `unset FOO' is bad.

I suppose you could do

	for var
	do
		export | grep \^$var\= >& /dev/null && unset $var
	done 

but that seems overkill.



Messages sorted by: Reverse Date, Date, Thread, Author