From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10620 invoked from network); 29 May 2000 13:33:42 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 29 May 2000 13:33:42 -0000 Received: (qmail 18879 invoked by alias); 29 May 2000 13:33:03 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3104 Received: (qmail 18872 invoked from network); 29 May 2000 13:32:56 -0000 Date: Mon, 29 May 2000 15:32:04 +0200 (MET DST) Message-Id: <200005291332.PAA13192@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-users@sunsite.auc.dk In-reply-to: Andy Spiegl's message of Mon, 29 May 2000 11:56:37 +0200 Subject: Re: strange alias effects Andy Spiegl wrote: > I just upgraded to 3.1.7-pre-4 and found something strange: > > In my dot-files I've got this (among others): > alias psl='ps -eo user,pid,ppid,cpu,pmem,rss,vsize,bsdtime,bsdstart,cmd --sort user,pid | \grep -v "bsdtime,bsdstart"' > alias pslS='ps -eo user,pid,ppid,cpu,pmem,rss,vsize,bsdtime,bsdstart,cmd --sort -size | \grep -v "bsdtime,bsdstart"' > look.for () { psl | \grep -iE "(^USER|$@)" | \grep -v "grep -iE" } > alias lookall='psl | grep -vE "(^($USERNAME|root|bin))|login"' > > When I type > look.for ssh-agent > I get: > look.for: command not found: psl > > "lookall" works as usual. > > After typing > look.for () { psl | \grep -iE "(^USER|$@)" | \grep -v "grep -iE" } > on the shell prompt, it works. I doubt that this worked before. Maybe you just didn't use it for some time and changed your file in the meantime? Adding that `if', for example? It was always the case that syntactical constructs like if/the/else and loops were parsed completely. So if you do: if [ -z ${OSTYPE:#solaris*} ]; then alias psl='ps -eo user,pid,ppid,pri,pcpu,vsz,pmem,stime,time,args | sort +1n -2 | \grep -v "stime,time"' alias pslS='ps -eo user,pid,ppid,pri,pcpu,vsz,pmem,stime,time,args | sort -k 6,6n | \grep -v "stime,time"' look () { psl | head -1; psl | \egrep -i $@ | \grep -v egrep } alias lookall='psl | \egrep -v "($USER|root|bin)"' else ... fi the whole thing is parsed at once. When it is executed, the alias is defined, but in this case the functions are already parsed, too. If the aliases were before the `if' or if you would split the whole thing in two: if [ -z ${OSTYPE:#solaris*} ]; then alias psl='ps -eo user,pid,ppid,pri,pcpu,vsz,pmem,stime,time,args | sort +1n -2 | \grep -v "stime,time"' alias pslS='ps -eo user,pid,ppid,pri,pcpu,vsz,pmem,stime,time,args | sort -k 6,6n | \grep -v "stime,time"' alias lookall='psl | \egrep -v "($USER|root|bin)"' else ... fi if [ -z ${OSTYPE:#solaris*} ]; then look () { psl | head -1; psl | \egrep -i $@ | \grep -v egrep } else ... fi it'll work, because then the shell gets the first if/then/else, executes it and then calls the parser to get the second one. It isn't special to zsh, either. All shells (have to) behave this way. Bye Sven P.S.: [[..]] is faster than [..]. -- Sven Wischnowsky wischnow@informatik.hu-berlin.de