Get the clean path to common posix tools used by GVM

This commit is contained in:
Joshua Bussdieker
2012-03-24 04:57:24 -07:00
parent e5d5641e31
commit 00ca5e9ce1
12 changed files with 25 additions and 21 deletions
+1 -1
View File
@@ -1 +1 @@
1.0.14
1.0.15
+3 -3
View File
@@ -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
;;
+1 -2
View File
@@ -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
+1 -3
View File
@@ -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
+2 -4
View File
@@ -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
-1
View File
@@ -1 +0,0 @@
LS_ERROR="Couldn't find ls"
+11
View File
@@ -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
+2 -2
View File
@@ -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"
-1
View File
@@ -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)"
+1 -1
View File
@@ -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
+2 -1
View File
@@ -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
+1 -2
View File
@@ -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