It's important to note from the discussion on return values that you cannot return strings or arrays from functions. The return keyword is not used in the same way as in structured programming languages, such as PHP or JavaScript. It is strictly for integers, and it's intended to describe the function's success or failure, and not any product of its work.
Instead, for values calculated by a function, you should have the function print the output that you want, and use it in suitable ways in scripts. Using our home example function, the following code uses command substitution to include the function's output in a message of its own:
bash$ home() { printf '%s\n' "$HOME" ; }
bash$ printf '%s\n' "Your home directory is: $(home)"
Your home directory is: /home/bashuser
You can treat function calls that emit output on the command line or in scripts the same way you can any other command that emits output; the shell does not treat them specially in this regard. For example, we could count the number of characters in our home output with wc, like so:
bash$ home | wc -c 15
Note that in this example, wc still counted the newline character we printed at the end of the directory name, hence the count of 15 and not 14.
Similarly, functions can read data from standard input as well. Suppose we write a grep_un function that uses the grep command to search for any line that contains the current user's username:
bash$ grep_un() { grep -F -- "$USER" ; }
If we feed input into this function from a pipe while running as bashuser, it will behave as if grep bashuser were running on that input:
bash$ getent passwd | grep_un bashuser:x:1003:1003:Bash User,,,:/home/bashuser:/bin/bash