2021-01-23 16:58:29 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -uo pipefail
|
|
|
|
|
|
|
|
[ -d "$DCTLENV_ROOT/versions" ] || log_error 'No versions of driftctl installed. Please install one with: dctlenv install [<version>]'
|
|
|
|
|
|
|
|
[[ -x "$DCTLENV_ROOT/versions" && -r "$DCTLENV_ROOT/versions" ]] \
|
|
|
|
|| log_error "dctlenv versions directory is inaccessible: $DCTLENV_ROOT/versions"
|
|
|
|
|
|
|
|
version_file="$(dctlenv-version-file)" \
|
2021-03-08 11:08:53 +00:00
|
|
|
&& log_debug "dctlenv-version-file reported: $version_file"
|
2021-01-23 16:58:29 +00:00
|
|
|
|
2021-03-08 11:08:53 +00:00
|
|
|
version_name="$(dctlenv-version-name 2>/dev/null)" \
|
|
|
|
&& log_debug "dctlenv-version-name reported: $version_name"
|
2021-01-23 16:58:29 +00:00
|
|
|
|
|
|
|
log_debug 'Listing versions...'
|
|
|
|
local_versions=($(\find "$DCTLENV_ROOT/versions" -type d -exec basename {} \; \
|
|
|
|
| tail -n +2 \
|
|
|
|
| sort -t'.' -k 1nr,1 -k 2nr,2 -k 3nr,3))
|
|
|
|
|
|
|
|
log_debug "Local versions: ${local_versions[@]}"
|
|
|
|
|
|
|
|
log_debug 'Printing versions...'
|
|
|
|
for local_version in ${local_versions[@]}; do
|
|
|
|
if [ "$local_version" == "$version_name" ]; then
|
|
|
|
echo "* $local_version (set by $version_file)"
|
|
|
|
else
|
|
|
|
echo " $local_version"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|