zsh-workers
 help / color / mirror / code / Atom feed
* Startup-file patch and some tcsh emulations
@ 1996-09-30  2:32 Geoff Wing
  1996-09-30  4:05 ` Richard Coleman
  1996-09-30 21:34 ` Bart Schaefer
  0 siblings, 2 replies; 4+ messages in thread
From: Geoff Wing @ 1996-09-30  2:32 UTC (permalink / raw)
  To: zsh-workers

Heyla,
  just a small patch to provide some emulations for csh/tcsh functions:
  glob, printenv, setenv, unsetenv, and a sample filetest (which could use
  quite a bit of improvement in checking options).  There are a couple of 
  others I was thinking of doing to ease any transition from tcsh.
  (BTW, anyone ever seen glob or filetest used?)

Note:
  In StartupFiles, all the files have a header line like
  Generic .zshrc file for zsh 2.7
  Umm, which version?

Question:
  Also, the parsing with [[ is a bit strict.  I had to use [ in filetest.
  Is it due to the order of parsing [[ coming before variable expansions
  or some such?  Maybe one of these years I'll have time to learn how
  zsh works!

Patch:
*** Functions/filetest.~1~	Mon Sep 30 12:01:16 1996
--- Functions/filetest	Mon Sep 30 12:00:21 1996
***************
*** 0 ****
--- 1,30 ----
+ #! /usr/local/bin/zsh
+ local OPTIONARG
+ if [ $# -lt 2 ] 
+ then
+ 	echo "filetest: Too few arguments."
+ elif [[ $1 > "-z" ]]
+ then
+ 	echo "filetest: Malformed file inquiry."	
+ else
+ 	OPTIONARG=$1
+ 	shift
+ 	if [ "$OPTIONARG" $1 ]
+ 	then 
+ 		echo -n 1
+ 	else
+ 		echo -n 0
+ 	fi
+ 	shift
+ 	repeat $#
+ 	do
+ 		if [ "$OPTIONARG" $1 ]
+ 		then 
+ 			echo -n " 1"
+ 		else
+ 			echo -n " 0"
+ 		fi
+ 		shift
+ 	done
+ 	echo
+ fi
*** Functions/glob.~1~	Mon Sep 30 12:01:33 1996
--- Functions/glob	Mon Sep 30 12:00:21 1996
***************
*** 0 ****
--- 1,11 ----
+ #! /usr/local/bin/zsh
+ if [ $# != 0 ]
+ then
+ 	echo -n $1
+ 	shift
+         repeat $#
+ 	do
+ 		echo -n "\000$1"
+ 		shift
+ 	done
+ fi
*** Functions/printenv.~1~	Mon Sep 30 12:01:21 1996
--- Functions/printenv	Mon Sep 30 12:00:21 1996
***************
*** 0 ****
--- 1,2 ----
+ #! /usr/local/bin/zsh
+ export
*** Functions/setenv.~1~	Mon Sep 30 12:01:24 1996
--- Functions/setenv	Mon Sep 30 12:00:21 1996
***************
*** 0 ****
--- 1,11 ----
+ #! /usr/local/bin/zsh
+ # setenv emulation
+ if [ $# -eq 0 ]
+ then
+ 	export
+ elif [ $# -le 2 ]
+ then
+ 	export $1=$2
+ else
+ 	echo "setenv: Too many arguments."
+ fi
*** 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
*** StartupFiles/zshrc	1996/05/02 22:57:04	2.0
--- StartupFiles/zshrc	1996/09/30 01:59:13
***************
*** 40,46 ****
  alias lsa='ls -ld .*'
  
  # Shell functions
! setenv() { export $1=$2 }  # csh compatibility
  
  # Where to look for autoloaded function definitions
  fpath=(~/.zfunc)
--- 40,49 ----
  alias lsa='ls -ld .*'
  
  # Shell functions
! if [[ -n "$DISPLAY" ]] ; then
!   print -Pn '^[]2;%~\a'		     # XTerm Title Change to %~ - the current
!   chpwd() { print -Pn '^[]2;%~\a' }  # directory in prompt escape sequences
! fi
  
  # Where to look for autoloaded function definitions
  fpath=(~/.zfunc)
***************
*** 50,59 ****
  # (the executable bit is not necessary, but gives
  # you an easy way to stop the autoloading of a
  # particular shell function).
! for dirname in $fpath
! do
!   autoload $dirname/*(.x:t)
! done
  
  # Global aliases -- These do not have to be
  # at the beginning of the command line.
--- 53,63 ----
  # (the executable bit is not necessary, but gives
  # you an easy way to stop the autoloading of a
  # particular shell function).
! if [[ -n "$fpath" ]] ; then
! 	for dirname in $fpath ; do
! 		autoload $dirname/*(.x:t)
! 	done
! fi
  
  # Global aliases -- These do not have to be
  # at the beginning of the command line.

-- 
Geoff Wing [mason@primenet.com.au]   PrimeNet - Internet Consultancy
  Web: http://www.primenet.com.au/   Facsimile: +61-3-9819 3788


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Startup-file patch and some tcsh emulations
  1996-09-30  2:32 Startup-file patch and some tcsh emulations Geoff Wing
@ 1996-09-30  4:05 ` Richard Coleman
  1996-09-30 21:34 ` Bart Schaefer
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Coleman @ 1996-09-30  4:05 UTC (permalink / raw)
  To: Geoff Wing; +Cc: zsh-workers

> Note:
>   In StartupFiles, all the files have a header line like
>   Generic .zshrc file for zsh 2.7
>   Umm, which version?
> 

The sample startup files are essentially generic versions of the
files I use.  They haven't changed much since the early beta's for
zsh 2.6.  They should work will all relatively recent (and probably
not so recent) versions of zsh.

rc


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Startup-file patch and some tcsh emulations
  1996-09-30  2:32 Startup-file patch and some tcsh emulations Geoff Wing
  1996-09-30  4:05 ` Richard Coleman
@ 1996-09-30 21:34 ` Bart Schaefer
  1996-10-01 17:52   ` Geoff Wing
  1 sibling, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 1996-09-30 21:34 UTC (permalink / raw)
  To: Geoff Wing, zsh-workers

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Startup-file patch and some tcsh emulations
  1996-09-30 21:34 ` Bart Schaefer
@ 1996-10-01 17:52   ` Geoff Wing
  0 siblings, 0 replies; 4+ messages in thread
From: Geoff Wing @ 1996-10-01 17:52 UTC (permalink / raw)
  To: zsh-workers; +Cc: schaefer

:On Sep 30, 12:32pm, Geoff Wing wrote:
:> Subject: Startup-file patch and some tcsh emulations
:>   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'

There are a couple of differences, one of which is that tcsh doesn't
terminate with a null, only seperates with them.  Another is the you
need to unset nullglob, so a function seems best to me.
Anyway, I had a spare couple of minutes and was just playing.  I'm sure 
there are several possible improvements in them.
-- 
Mason [G.C.W]  mason@werple.mira.net.au    "Hurt...Agony...Pain...LOVE-IT"


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1996-10-01 18:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-09-30  2:32 Startup-file patch and some tcsh emulations Geoff Wing
1996-09-30  4:05 ` Richard Coleman
1996-09-30 21:34 ` Bart Schaefer
1996-10-01 17:52   ` Geoff Wing

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).