Robert Elz <k...@munnari.oz.au> writes: > | Aliases are not used in bash scripts, unless bash is invoked in POSIX > | compatibility mode, or the "expand_aliases" shopt is turned on. > > I think that's what must have happened ... the infinite loop of > echo commands suggests that the function definition > > cmd() { echo "$@" ; } > > was converted by the alias info > > echo() { echo "$@" ; } > > and when you see that, it is obvious why cmd a b c (which becomes echo a b c) > just runs echo which runs echo which runs echo which ...
Heh -- but OTOH, if you use function cmd() { echo "$@" ; } you *don't* get that behavior. Looking at the manual page, it says ALIASES Aliases allow a string to be substituted for a word when it is used as the first word of a simple command. That makes it clear why the second case behaves as it does. But my reading of the definition of "simple commands" implies that function defintions are not simple commands, and alias substitution should not be done on them (that is, the initial part) in any case. Dale