Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,31 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
exec "${BASH_SOURCE%/*}/np.sh" "$@" | ||
function crossplatformReadlink { | ||
# http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac | ||
# http://stackoverflow.com/a/1116890 | ||
TARGET_FILE="$1" | ||
|
||
cd `dirname $TARGET_FILE` | ||
TARGET_FILE=`basename $TARGET_FILE` | ||
|
||
# Iterate down a (possible) chain of symlinks | ||
while [ -L "$TARGET_FILE" ] | ||
do | ||
TARGET_FILE=`readlink $TARGET_FILE` | ||
cd `dirname $TARGET_FILE` | ||
TARGET_FILE=`basename $TARGET_FILE` | ||
done | ||
|
||
# Compute the canonicalized name by finding the physical path | ||
# for the directory we're in and appending the target file. | ||
PHYS_DIR=`pwd -P` | ||
RESULT=$PHYS_DIR/$TARGET_FILE | ||
echo "$RESULT" | ||
} | ||
|
||
# Must be executed in this file. | ||
# Used to recursively call np and to find files to `source`. | ||
NP_SOURCE=$(crossplatformReadlink "$BASH_SOURCE") | ||
|
||
exec "${NP_SOURCE%/*}/np.sh" "$@" |
This file contains 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