Permalink
Browse files

interactive listing sort fixed

  • Loading branch information...
1 parent 3ea0210 commit 23c15341d4d2c62d830561ec721b4f74cd3fdb6c @jeromedecoster jeromedecoster committed Jul 10, 2013
Showing with 18 additions and 8 deletions.
  1. +18 −8 bin/n
View
26 bin/n
@@ -133,14 +133,24 @@ 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>.
#
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

0 comments on commit 23c1534

Please sign in to comment.