Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Dereference link for sshuttle launcher script if it's a symlink #7

wants to merge 1 commit into from

3 participants

Josh Russell Davies apenwarr

I have the launcher script symlinked into ~/bin, but it doesn't properly locate the python script as $(dirname $0) is ~/bin in that case.

This is a really ugly way to dereference that symlink, but I couldn't find any better way to do it with BSD coreutils. Seems like readlink -f for GNU coreutils would do the trick, but that doesn't work on OS X.
This might not be the best way to do it, but it works...

Russell Davies

This only works if the symlink is using relative paths. Perhaps a better solution would be using python's os.path.realpath:

apenwarr apenwarr closed this April 24, 2011

Merged a variant of this, will show up in my repo soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Apr 09, 2011
Josh Dereference symlink for sshuttle launch script 123a8e2
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 2 additions and 0 deletions. Show diff stats Hide diff stats

  1. 2  sshuttle
2  sshuttle
... ...
@@ -1,5 +1,7 @@
1 1
2 2
 DIR=$(dirname "$0")
+DIR="$(dirname ${DIR}/$(readlink -n $0))"
+DIR="$(cd $DIR;pwd)"
3 5
 if python2 -V 2>/dev/null; then
4 6
 	exec python2 "$DIR/" python2 "$@"
5 7

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.