From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-users@sunsite.auc.dk
Subject: Re: strange alias effects
Date: Mon, 29 May 2000 15:32:04 +0200 (MET DST) [thread overview]
Message-ID: <200005291332.PAA13192@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Andy Spiegl's message of Mon, 29 May 2000 11:56:37 +0200
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
next prev reply other threads:[~2000-05-29 13:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-05-29 9:56 Andy Spiegl
2000-05-29 10:13 ` Bart Schaefer
2000-05-29 10:27 ` Andy Spiegl
2000-05-29 13:32 ` Sven Wischnowsky [this message]
2000-05-29 13:47 ` Andy Spiegl
2000-05-29 17:24 ` Bart Schaefer
2000-05-29 11:44 ` Andrej Borsenkow
2000-05-29 12:06 ` Andrej Borsenkow
2000-05-29 12:13 ` Andy Spiegl
2000-05-29 12:30 ` Andrej Borsenkow
2000-05-29 12:59 ` Andy Spiegl
[not found] ` <000301bfc96e$cf7af2b0$21c9ca95@mow.siemens.ru>
2000-05-29 13:13 ` Andy Spiegl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200005291332.PAA13192@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-users@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).