Skip to content

Commit

Permalink
Resolve symlinks when executing buck on unix
Browse files Browse the repository at this point in the history
Summary:
If buck is checked out in $HOME/devtools/buck yet run via a symlink in /usr/bin it
will not run, since we attempt to resolve "/usr/bin/../programs". Eagerly resolving
symlinks before executing resolves this problem.

Test Plan: /usr/bin/buck --help
  • Loading branch information
shs96c authored and natthu committed Nov 13, 2014
1 parent 28dc1ac commit 3e451f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion bin/buck
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
#!/bin/sh
exec python "$(dirname $0)"/../programs/buck.py "$@"

# Resolve symlinks if necessary, otherwise madness will follow.
# On a GNU system, we could use "-f" to follow all symlinks. BSD based
# systems don't have this flag. *sigh*
BUCK_PATH="`readlink $0`"
if [ -z "$BUCK_PATH" ]; then
BUCK_PATH="$0"
fi

exec python "$(dirname $BUCK_PATH)/../programs/buck.py" "$@"
6 changes: 6 additions & 0 deletions bin/buckd
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#!/bin/sh

BUCK_PATH="`readlink $0`"
if [ -z "$BUCK_PATH" ]; then
BUCK_PATH="$0"
fi

exec python "$(dirname $0)"/../programs/buckd.py "$@"

0 comments on commit 3e451f8

Please sign in to comment.