I have this setup
file:
function latest {
count=${1:-5} ;
echo "Just changed"
ls -lrtd * | tail -$count ;
}
I call it:
. setup
Then I ask bash if the latest
function is defined:
>type latest
latest is a function
latest ()
{
count=${1:-5};
echo "Just changed";
ls --color=auto -lrtd * | tail -$count
}
Just changed
is an arbitrary string that I used to make sure I was not looking at a definition of latest
from another file.
And the question is: why is Bash adding the --color=auto
to the ls
command (where it is of no use since the output is piped anyway). And yes, on my shell ls
is aliased to ls --color=auto
, and if I remove the alias this doesn't happen. But I thought aliases where not used in functions and in any case this substitution happened at function definition time?