diff --git a/bootstrap.sh b/bootstrap.sh index 12f0681..a83b46c 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -CBUILD_BOOTSTRAP_VERSION=1.0.1 +CBUILD_BOOTSTRAP_VERSION=1.0.2 set -eo pipefail function version_parse { @@ -34,13 +34,14 @@ function print_version_list { dir_global="/usr/local/share/cbuild" files="" if [ -d "$dir_local" ]; then - files+="$(find $dir_local -name 'CBUILD_VERSION')" + files+=$(find "$dir_local" -maxdepth 2 -name 'CBUILD_VERSION') fi if [ -d "$dir_global" ]; then - files+="$(find $dir_global -name 'CBUILD_VERSION')" + files+=$(find "$dir_global" -maxdepth 2 -name 'CBUILD_VERSION') fi for f in $files; do - cat $f | sed '$a\' + cat $f + echo " at $(dirname $f)" done | sort -V } @@ -68,18 +69,18 @@ do case "${args[i]}" in '-v' | '--version') echo "cbuild-bootstrap v$CBUILD_BOOTSTRAP_VERSION" + echo "list of installed cbuild versions:" + print_version_list + exit 0 ;; '-h' | '--help') print_help + exit 0 ;; '-c' | '--config') i=$((i+1)) project_config_path="${args[i]}" ;; - '--list-versions') - print_version_list - exit 0 - ;; *) ;; esac @@ -93,9 +94,9 @@ if [ -z "$CBUILD_VERSION" ]; then else echo "project config not found" echo "list of installed cbuild versions:" - versions=$(print_version_list) - - echo "$versions" + print_version_list + # cut installation directories from list + versions=$(print_version_list | cut -d ' ' -f 1) latest_version=$(echo "$versions" | tail -n 1) echo "select version (default=$latest_version):" read -r CBUILD_VERSION