forked from liyu95/DeepSimulator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a readlinkf.sh implementation in the repo instead of native readlink
This improves support for macOS, since the `-f` flag doesn't exist in the macOS implementation of readlink. Not sure if more is needed.
- Loading branch information
1 parent
3c867c2
commit 784341f
Showing
2 changed files
with
30 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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
|
||
# Below is an implementation of readlink -f | ||
# Taken from https://stackoverflow.com/a/1116890/1709587, authored by | ||
# Keith Smith, and CC-licensed. | ||
# This is used in DeepSimulator to support readlink -f behaviour on macOS, | ||
# since the default readlink implementation on macOS doesn't accept the -f | ||
# flag. | ||
|
||
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 |