Last active
December 30, 2015 21:49
-
-
Save ilovezfs/7890169 to your computer and use it in GitHub Desktop.
cmd.sh anywhere
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/cmd.sh b/cmd.sh | |
index 0b0f9b6..9f0d8cf 100755 | |
--- a/cmd.sh | |
+++ b/cmd.sh | |
@@ -1,8 +1,9 @@ | |
#!/bin/bash | |
-cmd=$1 | |
+[[ $# -eq 0 ]] && echo "error: need to specify what command to run" >&2 && exit 1 | |
+cmd="$1" | |
shift | |
-topdir=`pwd` | |
+topdir="$(/usr/bin/python -c "import os,sys; print os.path.dirname(os.path.realpath(sys.argv[1]))" "$0")" | |
for lib in nvpair uutil zpool zfs zfs_core; do | |
export DYLD_LIBRARY_PATH=$topdir/lib/lib${lib}/.libs:$DYLD_LIBRARY_PATH | |
done | |
@@ -12,4 +13,4 @@ done | |
#echo PATH=$PATH | |
#echo DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH | |
-exec ./cmd/$cmd/.libs/$cmd "$@" | |
+exec "$topdir"/cmd/$cmd/.libs/$cmd "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment