diff --git a/VERSION b/VERSION index 5b09c67..a970716 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.14 +1.0.15 diff --git a/scripts/completion b/scripts/completion index 9c92bc8..8d177ff 100644 --- a/scripts/completion +++ b/scripts/completion @@ -1,7 +1,7 @@ +. $GVM_ROOT/scripts/functions/tools + _gvm() { - LS_PATH=`which ls` || return 1 - local cur prev opts base COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" @@ -58,7 +58,7 @@ _gvm() install) [ ! -d $GVM_ROOT/archive/go ] && return 1 [[ $COMP_CWORD > 2 ]] && return 1 - local version=$(for x in `hg tags -R $GVM_ROOT/archive/go | awk '{print $1}' | grep -E "release|tip"`; do echo ${x} ; done ) + local version=$(for x in `hg tags -R $GVM_ROOT/archive/go | awk '{print $1}' | $GREP_PATH -E "release|tip"`; do echo ${x} ; done ) COMPREPLY=( $(compgen -W "${version}" -- ${cur}) ) return 0 ;; diff --git a/scripts/diff b/scripts/diff index 049f121..bff9230 100755 --- a/scripts/diff +++ b/scripts/diff @@ -1,11 +1,10 @@ #!/bin/bash . $GVM_ROOT/scripts/functions -LS_PATH=`which ls` || display_error "$LS_ERROR" || return 1 version=$1 if [ "$version" != "" ]; then - fuzzy_match=`$LS_PATH $GVM_ROOT/gos | sort | grep "$version" | head -n 1 | grep "$version"` || + fuzzy_match=`$LS_PATH $GVM_ROOT/gos | $SORT_PATH | $GREP_PATH "$version" | $HEAD_PATH -n 1 | $GREP_PATH "$version"` || display_error "Invalid version $version" foldername=$GVM_ROOT/gos/$fuzzy_match diff --git a/scripts/env/pkgset-use b/scripts/env/pkgset-use index 0af132a..88d2e8b 100644 --- a/scripts/env/pkgset-use +++ b/scripts/env/pkgset-use @@ -18,15 +18,13 @@ function display_message() { } function gvm_pkgset_use() { - LS_PATH=`which ls` || display_error "$LS_ERROR" || return 1 - [[ "$1" != "" ]] || display_error "Please specify a package set" || return 1 [[ "$gvm_go_name" != "" ]] || display_error "No Go version selected" || return 1 - fuzzy_match=`$LS_PATH $GVM_ROOT/environments | sort | grep "$gvm_go_name@" | grep "$1" | head -n 1` || + fuzzy_match=`$LS_PATH $GVM_ROOT/environments | $SORT_PATH | $GREP_PATH "$gvm_go_name@" | $GREP_PATH "$1" | $HEAD_PATH -n 1` || display_error "Invalid package set" || return 1 export PATH=$GVM_PATH_BACKUP diff --git a/scripts/env/use b/scripts/env/use index 5a2d8c9..dd38798 100644 --- a/scripts/env/use +++ b/scripts/env/use @@ -1,5 +1,5 @@ #!/bin/bash -. $GVM_ROOT/scripts/function/errors +. $GVM_ROOT/scripts/function/tools function display_error() { tput sgr0 @@ -18,11 +18,9 @@ function display_message() { } function gvm_use() { - LS_PATH=`which ls` || display_error "$LS_ERROR" || return 1 - [[ "$1" != "" ]] || display_error "Please specifiy the version" || return 1 - fuzzy_match=`$LS_PATH $GVM_ROOT/gos | sort | grep "$1" | head -n 1 | grep "$1"` || + fuzzy_match=`$LS_PATH $GVM_ROOT/gos | $SORT_PATH | $GREP_PATH "$1" | $HEAD_PATH -n 1 | $GREP_PATH "$1"` || display_error "Invalid version $1" || return 1 export PATH=$GVM_PATH_BACKUP diff --git a/scripts/function/errors b/scripts/function/errors deleted file mode 100644 index 6c19163..0000000 --- a/scripts/function/errors +++ /dev/null @@ -1 +0,0 @@ -LS_ERROR="Couldn't find ls" diff --git a/scripts/function/tools b/scripts/function/tools new file mode 100644 index 0000000..e5f5d59 --- /dev/null +++ b/scripts/function/tools @@ -0,0 +1,11 @@ +#!/bin/bash +LS_ERROR="Couldn't find ls" +GREP_ERROR="Couldn't find grep" +SORT_ERROR="Couldn't find sort" +HEAD_ERROR="Couldn't find head" + +LS_PATH=`unalias ls &> /dev/null; which ls` || display_error "$LS_ERROR" || return 1 +GREP_PATH=`unalias grep &> /dev/null; which grep` || display_error "$GREP_ERROR" || return 1 +SORT_PATH=`unalias sort &> /dev/null; which sort` || display_error "$SORT_ERROR" || return 1 +HEAD_PATH=`unalias head &> /dev/null; which head` || display_error "$HEAD_ERROR" || return 1 + diff --git a/scripts/install b/scripts/install index 4d56ba5..d20e2f3 100755 --- a/scripts/install +++ b/scripts/install @@ -48,7 +48,7 @@ download_source() { } check_tag() { - version=`hg tags -R $GO_CACHE_PATH | awk '{print $1}' | sort | grep "$VERSION" | head -n 1 | grep "$VERSION"` + version=`hg tags -R $GO_CACHE_PATH | awk '{print $1}' | $SORT_PATH | $GREP_PATH "$VERSION" | $HEAD_PATH -n 1 | $GREP_PATH "$VERSION"` } update_source() { @@ -150,7 +150,7 @@ main() { GVM_GOINSTALL="goinstall" which goinstall &> /dev/null || GVM_GOINSTALL="go get" - x="`hg tags -R ~/.gvm/archive/go`"; echo ${x#*b0819469a6df} | grep "$version " &> /dev/null + x="`hg tags -R ~/.gvm/archive/go`"; echo ${x#*b0819469a6df} | $GREP_PATH "$version " &> /dev/null if [[ "$?" == "1" ]]; then install_gb || display_warning "Failed to install gb" install_gpkg || display_warning "Failed to install gpkg" diff --git a/scripts/list b/scripts/list index c3312f1..9569dcd 100755 --- a/scripts/list +++ b/scripts/list @@ -1,6 +1,5 @@ #!/bin/bash . $GVM_ROOT/scripts/functions -LS_PATH=`which ls` || display_error "$LS_ERROR" || return 1 echo display_message "gvm gos (installed)" diff --git a/scripts/listall b/scripts/listall index 902b955..69776f9 100755 --- a/scripts/listall +++ b/scripts/listall @@ -32,7 +32,7 @@ read_command_line $@ echo display_message "gvm gos (available)" echo -versions=`curl -s https://go.googlecode.com/hg/.hgtags | awk '{ print $2 }' | grep "$tag_filter" | sort` +versions=`curl -s https://go.googlecode.com/hg/.hgtags | awk '{ print $2 }' | $GREP_PATH "$tag_filter" | $SORT_PATH` if [[ $? -ne 0 ]]; then display_error "Failed to get version list from Google" fi diff --git a/scripts/templates/binary b/scripts/templates/binary index d037f5e..35cfa1e 100644 --- a/scripts/templates/binary +++ b/scripts/templates/binary @@ -1,5 +1,6 @@ #!/bin/bash -echo $1 | sed -n -e '/_.*_/ p' | grep "_" &> /dev/null +. $GVM_ROOT/scripts/functions/tools +echo $1 | sed -n -e '/_.*_/ p' | $GREP_PATH "_" &> /dev/null if [ "$?" == "0" ]; then version=`echo $1 | sed 's/_\(.*\)_/\1/'` if [ ! -f $GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name/pkg.gvm/{{package_name}}/$version/bin/{{binary_name}} ]; then diff --git a/scripts/uninstall b/scripts/uninstall index 2dced12..1facb66 100755 --- a/scripts/uninstall +++ b/scripts/uninstall @@ -1,11 +1,10 @@ #!/bin/bash . $GVM_ROOT/scripts/functions -LS_PATH=`which ls` || display_error "$LS_ERROR" || return 1 [[ "$1" == "" ]] && display_error "Please specifiy the version" -fuzzy_match=`$LS_PATH $GVM_ROOT/gos | sort | grep "$1" | head -n 1 | grep "$1"` || +fuzzy_match=`$LS_PATH $GVM_ROOT/gos | $SORT_PATH | $GREP_PATH "$1" | $HEAD_PATH -n 1 | $GREP_PATH "$1"` || display_error "Invalid version $1" if [ -d $GVM_ROOT/gos/$fuzzy_match ]; then