I am running a bash script, and it is strange that after a line of calling function, echo
in the called function does not print anything.
$ cat test.sh
#!/bin/bash
foo() {
echo 1 # not print in stdout
echo "I want to return this string"
}
main() {
echo 0 # print in stdout
count="$(foo)"
}
main "$@"
$ ./test.sh
0
How do I get called functions to echo to stdout?
2