In a bash script, I want the user to enter a path to an application, and then launch that application. By default, the application is expected to be in the user's own directory. The following script works for me on Mac OS X, but it is not particularly elegant:
path_default="~/neo4j/bin/neo4j"
read -p "Enter path to neo4j [$path_default]: " path
path="${path:-$path_default}"
if [[ ${path:0:1} == "~" ]]; then
path="/Users/$USER"${path#"~"}
fi
$path start
How can I improve this so that it will work on any platform?