Problem: aliases and exec in shells

John R. MacMillan john at sco.COM
Sat Nov 3 02:34:58 AEST 1990


evans at decvax.dec.com (Marc Evans) writes:

|In both ksh and csh, on many different vendors OS's that I have tried, if
|foo is an alias for something, the alias is not used. For example, consider
|the following:
|
|	% csh
|	% alias ls 'ls -F'
|	% exec ls
|
|The result would be simply the results of running the ls command without
|any arguments, rather than running the ls command with the argument -F.

In the ksh manual, you'll probably find this behaviour documented in
the section on alias expansion.  Alias expansion is performed on the
first word, but not its arguments, barring some exceptions.  One
exception can get you the behaviour you want:  if the first word is an
alias whose expanded value ends in a space, alias expansion is
performed on the next word.  So you can get the behaviour you want in
ksh with:

$ ksh
$ alias ls='ls -F'
$ alias exec='exec '
$ exec ls

Also handy for nohup.
-- 
John R. MacMillan       | I'm in love with a McDonald's girl
SCO Canada, Inc.        | She's an angel in a polyester uniform.
john at sco.COM            |      -- barenaked ladies



More information about the Comp.unix.programmer mailing list