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

Re: alias bug on solaris machines



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@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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