The shell certainly supports recursion. But your function takes arguments, and you pass it stdin. Also, you really don't have to parse ls output . Consider this:
listit() { while [ "$1" ]; do if [ -d "$1" ]; then listit "$1"/* else printf '%s\n' "$1" fi shift done } listit *
If you really want to read stdin, you will have to rewrite listit to do this. This is difficult because you only get one standard input, and every recursive call will try to own it. File names are a simple thing available as arguments across the globe, so I will stick with this.
source share