summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authortv <tv@iiso>2011-09-18 23:02:15 +0200
committertv <tv@iiso>2011-09-18 23:03:46 +0200
commitbea490c675a6f6b5d40c4d6be86161dfc13a5f78 (patch)
treea7ad10e6ee27afac654e16a9230f3714d45df079 /util
parent820e9babae95ad58b26f25983a4fd3aaebd4ac65 (diff)
//util lgoinstall: allow arbitrary directories
Diffstat (limited to 'util')
-rwxr-xr-xutil/bin/lgoinstall26
1 files changed, 16 insertions, 10 deletions
diff --git a/util/bin/lgoinstall b/util/bin/lgoinstall
index 4cd0e852..37ce6e16 100755
--- a/util/bin/lgoinstall
+++ b/util/bin/lgoinstall
@@ -1,17 +1,21 @@
#! /bin/sh
#
-# usage: lgoinstall
+# usage: lgoinstall [path [OPTIONS...]]
#
-# This script tries to goinstall $PWD
+# This script tries to goinstall ${OPTIONS...} local/$(basename $path)
#
-# target=local/$(basename $PWD)
+# path defaults to $PWD
+#
+# target=local/$(basename $path)
# ensure there's a symlink local/$target somewhere in $GOROOT or $GOPATH
-# goinstall local/$(dirname $PWD)
+# goinstall $target
+#
+# TODO use the same argument order as goinstall
#
set -euf
#fqtarget="$(readlink -f "$PWD")"
-fqtarget="$PWD"
+fqtarget="$(cd "${1-$PWD}" && echo "$PWD")"
target="local/$(basename "$fqtarget")"
#
@@ -75,12 +79,14 @@ sub() {
path="${GOROOT-}${GOPATH+:$GOPATH}"
#
-# if there's a src/$target that points to $PWD, then succeed
+# if there's a src/$target that points to $fqtarget, then succeed
#
if x="`resolve "$path" src/$target | xargstest "$fqtarget" = %fqx`"
then
- echo "good $target: $x -> $PWD" >&2
- exec goinstall "$target"
+ echo "good $target: $x -> $fqtarget" >&2
+ shift # off $1 = $fqtarget
+ echo goinstall "$@" "$target" >&2
+ exec goinstall "$@" "$target"
fi
#
@@ -94,10 +100,10 @@ then
fi
#
-# if we've no Go-source in $PWD then die to prevent clobbering $GOPATH & co.
+# if we've no Go-source in $fqtarget then die to prevent clobbering $GOPATH.
#
if ! ls | grep '\.go$'; then
- echo "Your \$PWD seems to contain no Go-source... abort." >&2
+ echo "$1 seems to contain no Go-source... abort." >&2
exit 23
fi