IMPORTANT: do not use eval! (I learned this later..)
In a function, eval
expands sleep
to its alias, so I prevent the endless loop this way:
function FUNCexecEcho() {
echo "EXEC: $@";
shopt -u expand_aliases
eval "$@";
shopt -s expand_aliases
};
alias sleep='FUNCexecEcho sleep ';
sleep 10
But then, all other aliases will stop working...
How to prevent expansion only to one arbitrary alias inside this function?
PS.: the endless loop only happens on the second time you execute sleep 10