aliases vs. shell functions (was Hard links vs. Soft links)
Hans Mulder
hansm at cs.kun.nl
Tue Aug 28 20:04:40 AEST 1990
In article <738 at primerd.PRIME.COM> milgr at teapot.prime.COM (Marc Milgram) writes:
>In article <2866 at wyse.wyse.com>, bob at wyse.wyse.com (Bob McGowen x4312
>dept208) writes:
>|>As for using aliases for this function, only csh and ksh (if you have it)
>|>would be able to do this.
.
.
.
>aliases work in the bourne shell
No, they don't.
> (at least all of the /bin/sh's that I have used.)
Apparently, you have only used SysV-derived Un*xen.
>For example:
>
>ls()
>{
> /bin/ls -CFb $@
>}
This is not an alias, it's a shell function.
Some /bin/sh's support these, others don't.
In particular, the /bin/sh that came with V7 didn't and
consequently the /bin/sh that comes with 4.[0-3]BSD still doesn't.
The Korn shell supports both aliases and shell functions; you can say either:
alias ls="/bin/ls -CBb"
or:
ls()
{
/bin/ls -CFb "$@" # Note the ""
}
and the effect is pretty much the same.
Hope this clarifies things a bit,
Hans Mulder hansm at cs.kun.nl
More information about the Comp.unix.wizards
mailing list