Skip to content

Instantly share code, notes, and snippets.

@ilovezfs
Last active December 30, 2015 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilovezfs/7890169 to your computer and use it in GitHub Desktop.
Save ilovezfs/7890169 to your computer and use it in GitHub Desktop.
cmd.sh anywhere
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