Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interactive listing sort fixed #142

Merged
merged 1 commit into from
Jul 10, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions bin/n
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -133,14 +133,24 @@ check_current_version() {
fi 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 installed versions with <selected>.
# #


display_versions_with_selected() { display_versions_with_selected() {
selected=$1 selected=$1
echo echo
for dir in $VERSIONS_DIR/*; do for dir in `versions_paths`; do
local version=${dir##*/} local version=${dir##*/}
local config=`test -f $dir/.config && cat $dir/.config` local config=`test -f $dir/.config && cat $dir/.config`
if test "$version" = "$selected"; then if test "$version" = "$selected"; then
Expand All @@ -157,7 +167,7 @@ display_versions_with_selected() {
# #


list_versions_installed() { list_versions_installed() {
for dir in $VERSIONS_DIR/*; do for dir in `versions_paths`; do
local version=${dir##*/} local version=${dir##*/}
echo $version echo $version
done done
Expand Down Expand Up @@ -272,12 +282,12 @@ install_node() {
local dots=`echo $version | sed 's/[^.]*//g'` local dots=`echo $version | sed 's/[^.]*//g'`
if test ${#dots} -eq 1; then if test ${#dots} -eq 1; then
version=`$GET 2> /dev/null http://nodejs.org/dist/ \ version=`$GET 2> /dev/null http://nodejs.org/dist/ \
| egrep -o '[0-9]+\.[0-9]+\.[0-9]+' \ | egrep -o '[0-9]+\.[0-9]+\.[0-9]+' \
| egrep -v '^0\.[0-7]\.' \ | egrep -v '^0\.[0-7]\.' \
| egrep -v '^0\.8\.[0-5]$' \ | egrep -v '^0\.8\.[0-5]$' \
| sort -u -k 1,1n -k 2,2n -k 3,3n -t . \ | sort -u -k 1,1n -k 2,2n -k 3,3n -t . \
| egrep ^$version \ | egrep ^$version \
| tail -n1` | tail -n1`


test $version || abort "invalid version ${1#v}" test $version || abort "invalid version ${1#v}"
fi fi
Expand Down