[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: redirect of "ls --color" causes problems



Hugh Saunders <hugh@mjr.org> writes:
> On Sat, Jan 25, 2003 at 11:54:29AM -0500, David Z Maze wrote:
>>   'chsh /bin/zsh', then ls() { /bin/ls --color=auto --classify "$@"; }
> please explain...

The syntax for aliases is substantially different in Bourne-like
shells than in C-like shells.  I tend to find csh syntax more arcane
than necessary, and using a similar shell to the one shell scripts are
written for is helpful, particularly for doing Deep Shell Magic.
http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ explains in great
detail why you shouldn't use csh and derivatives for scripting.

So while bash and zsh have aliases, you can't actually do much with
them.  Bourne-like shells offer a feature called shell functions,
which use similar syntax to full-blown shell scripts.  So

  ls() { /bin/ls --color=auto --classify "$@"; }

might be put in a .bashrc or a .zshrc to define a shell alias for ls
that does what the original poster asked for.

-- 
David Maze         dmaze@debian.org      http://people.debian.org/~dmaze/
"Theoretical politics is interesting.  Politicking should be illegal."
	-- Abra Mitchell



Reply to: