Subject: RE: syntax highlighting in vim
From: [email-masked] (Eric Blake)
To: "Williams, Gerald S (Jerry)" <[email-masked]>, [email-masked]
Cc: Alireza Ghasemi <[email-masked]>
Date: Wed, 23 Nov 2005 16:21:01 +0000

> > The use of a trailing space in the alias controls
> > whether the next word on the command line will also
> > be subject to alias expansion;
> 
> True, but I prefer not to make assumptions about how
> people are using aliases. The space at the end of the
> alias makes it behave like the unaliased ls in that
> regard.

Wrong again - alias expansion in bash starts ONLY at the
first word, and only progresses on to the next word if
the current alias expansion ended in a space.  So if
ls is not aliased, the second word is never even checked
for alias expansion.  Therefore, putting a space at the
end of an alias for ls actually maked ls behave
DIFFERENTLY than the unaliased version, since it is now
telling bash to alias expand the next argument.

$ cd /tmp
$ touch file
$ alias ls
bash: alias: ls: not found
$ alias file=oops
$ ls file
file
$ alias ls='ls '
$ ls file
ls: oops: No such file or directory
$ \ls file
file

Furthermore, in 99.9% of the cases, a shell function
can do the same thing as an alias.

$ unalias ls
$ ls() { command ls --color=auto "$@" }
$

The exceptional cases are when you do funky things
like those mentioned in
http://www.chiark.greenend.org.uk/~sgtatham/aliases.html.

I kind of like this hack that makes find temporarily supress globbing,
so that I can type "find -name *.c" instead of "find -name '*.c'":

alias find='_find() { command find "$@"; set +f; }; set -f; _find'

--
Eric Blake
volunteer cygwin bash maintainer

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/