* alias bug on solaris machines
@ 2007-12-20 13:46 Andy Spiegl
2007-12-20 14:05 ` Peter Stephenson
0 siblings, 1 reply; 4+ messages in thread
From: Andy Spiegl @ 2007-12-20 13:46 UTC (permalink / raw)
To: ZSH User List
Hi,
I discovered a very strange behaviour on my solaris machine.
Aliases are treated like global aliases in some cases:
$ zsh -f
% echo $ZSH_VERSION
4.3.2
% alias
run-help=man
which-command=whence
% GREPCOLOR=""
% alias grep="grep $GREPCOLOR"
% echo "foo man bar" >> /tmp/bla
% grep run-help /tmp/bla
foo man bar
% uname -a
SunOS cms-qs 5.9 Generic_122300-12 sun4u sparc SUNW,Sun-Fire-V240
% cat /etc/release
Solaris 9 9/05 HW s9s_u9wos_06b SPARC
Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
Use is subject to license terms.
Assembled 25 September 2006
Thanks,
Andy.
--
Great spirits have always encountered violent opposition from
mediocre minds. - Albert Einstein
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: alias bug on solaris machines
2007-12-20 13:46 alias bug on solaris machines Andy Spiegl
@ 2007-12-20 14:05 ` Peter Stephenson
2007-12-20 14:38 ` alias bug on solaris machines - DOH! Andy Spiegl
2007-12-20 16:24 ` alias bug on solaris machines Bart Schaefer
0 siblings, 2 replies; 4+ messages in thread
From: Peter Stephenson @ 2007-12-20 14:05 UTC (permalink / raw)
To: ZSH User List
Andy Spiegl wrote:
> I discovered a very strange behaviour on my solaris machine.
> Aliases are treated like global aliases in some cases:
>
> $ zsh -f
> % echo $ZSH_VERSION
> 4.3.2
> % alias
> run-help=man
> which-command=whence
> % GREPCOLOR=""
> % alias grep="grep $GREPCOLOR"
> % echo "foo man bar" >> /tmp/bla
> % grep run-help /tmp/bla
> foo man bar
That's actually expected behaviour. It's documented that aliases that
end with a space cause the following word to be expanded as an alias.
Since GREPCOLOR is empty, the alias for grep does end with a space.
You ought to do something like
[[ -n $GREPCOLOR ]] && alias grep="grep $GREPCOLOR"
or
alias grep="grep${GREPCOLOR:+ $GREPCOLOR}"
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: alias bug on solaris machines - DOH!
2007-12-20 14:05 ` Peter Stephenson
@ 2007-12-20 14:38 ` Andy Spiegl
2007-12-20 16:24 ` alias bug on solaris machines Bart Schaefer
1 sibling, 0 replies; 4+ messages in thread
From: Andy Spiegl @ 2007-12-20 14:38 UTC (permalink / raw)
To: ZSH User List
Hi Peter,
> That's actually expected behaviour. It's documented ...
That explains it all! I think I have never read this line in the manpage.
Thanks a lot,
Andy.
--
As I said before, I never repeat myself!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: alias bug on solaris machines
2007-12-20 14:05 ` Peter Stephenson
2007-12-20 14:38 ` alias bug on solaris machines - DOH! Andy Spiegl
@ 2007-12-20 16:24 ` Bart Schaefer
1 sibling, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2007-12-20 16:24 UTC (permalink / raw)
To: ZSH User List
On Dec 20, 2:05pm, Peter Stephenson wrote:
} Subject: Re: alias bug on solaris machines
}
} That's actually expected behaviour. It's documented that aliases that
} end with a space cause the following word to be expanded as an alias.
} Since GREPCOLOR is empty, the alias for grep does end with a space.
}
} You ought to do something like
}
} [[ -n $GREPCOLOR ]] && alias grep="grep $GREPCOLOR"
Or just
alias grep='grep $GREPCOLOR'
(single quotes) which would wait to expand the variable until the time
grep is run, which seems more like what you'd want anyway.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-12-20 16:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-20 13:46 alias bug on solaris machines Andy Spiegl
2007-12-20 14:05 ` Peter Stephenson
2007-12-20 14:38 ` alias bug on solaris machines - DOH! Andy Spiegl
2007-12-20 16:24 ` alias bug on solaris machines Bart Schaefer
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).