Why some user functions don't get recognised by bash?
- by strapakowsky
I can define a function like:
myfunction () { ls -R "$1" ; }
And then
myfunction .
just works.
But if I do
echo "myfunction ." | sh
echo "myfunction ." | bash
the messages are:
sh: myfunction: not found
bash: line 1: myfunction: command not found
Why? And how can I call a function that comes from a string if not by piping it to sh or bash?
I know there is this command source, but I am confused of when I should use source and when sh or bash. Also, I cannot pipe through source. To add to confusion, there is this command . that seems to have nothing to do with the "." that means "current directory".