This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: syntax highlighting in vim

> > 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
$ alias ls='ls '
$ ls file
ls: oops: No such file or directory
$ \ls 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

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:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]