Fix and support sh (not bash) script standard.

* sh is not support `$()` syntax. replacing to ``.
* `set -e` is good practice on shell scripting.
* shell function have to be defined before using it.
Oh! I forgot to replace this lines `$()`!
:disappointed_relieved: