0
0
mirror of https://github.com/tj/n.git synced 2024-11-25 07:39:21 +01:00

interactive listing sort fixed

This commit is contained in:
jerome@work 2013-07-10 18:05:18 +02:00
parent 3ea021043f
commit 23c15341d4

26
bin/n
View File

@ -133,6 +133,16 @@ check_current_version() {
fi
}
#
# Display sorted versions directories paths
#
versions_paths() {
ls -d $VERSIONS_DIR/* \
| egrep "/[0-9]+\.[0-9]+\.[0-9]+$" \
| sort -k 1,1n -k 2,2n -k 3,3n -t .
}
#
# Display installed versions with <selected>.
#
@ -140,7 +150,7 @@ check_current_version() {
display_versions_with_selected() {
selected=$1
echo
for dir in $VERSIONS_DIR/*; do
for dir in `versions_paths`; do
local version=${dir##*/}
local config=`test -f $dir/.config && cat $dir/.config`
if test "$version" = "$selected"; then
@ -157,7 +167,7 @@ display_versions_with_selected() {
#
list_versions_installed() {
for dir in $VERSIONS_DIR/*; do
for dir in `versions_paths`; do
local version=${dir##*/}
echo $version
done
@ -272,12 +282,12 @@ install_node() {
local dots=`echo $version | sed 's/[^.]*//g'`
if test ${#dots} -eq 1; then
version=`$GET 2> /dev/null http://nodejs.org/dist/ \
| egrep -o '[0-9]+\.[0-9]+\.[0-9]+' \
| egrep -v '^0\.[0-7]\.' \
| egrep -v '^0\.8\.[0-5]$' \
| sort -u -k 1,1n -k 2,2n -k 3,3n -t . \
| egrep ^$version \
| tail -n1`
| egrep -o '[0-9]+\.[0-9]+\.[0-9]+' \
| egrep -v '^0\.[0-7]\.' \
| egrep -v '^0\.8\.[0-5]$' \
| sort -u -k 1,1n -k 2,2n -k 3,3n -t . \
| egrep ^$version \
| tail -n1`
test $version || abort "invalid version ${1#v}"
fi