Follow by
https://stackoverflow.com/questions/1809899/how-can-i-assign-the-output-of-a-function-to-a-variable-using-bash and How do I assign the output of a command to a variable?
I wrote
function getos(){
# http://stackoverflow.com/a/27776822/1637673
case "$(uname -s)" in
Darwin)
OS='mac'
;;
Linux)
OS='linux'
;;
CYGWIN*|MINGW32*|MSYS*)
OS='win'
;;
# Add here more strings to compare
# See correspondence table at the bottom of this answer
*)
OS='other'
;;
esac
echo $OS
}
echo $(getos)
OS=${getos}
echo ${OS} # show nothing
echo $OS # show nothing
echo $(OS) # line 36
But
bash common.sh got
linux
common.sh: line 36: OS: command not found
What's the problem ??