open-discussion > runROBEX with BSD or OS X (readlink -f issue)
Jul 31, 2017  04:07 PM | LabNuero CogDevel - UPMC
runROBEX with BSD or OS X (readlink -f issue)
OS X (Mac) uses BSD's readlink which does not have the -f option used by runROBEX.sh
readlink: illegal option -- f


I'm getting around this by redefining readlink at the top of the runROBEX.sh file

realreadlink=$(which readlink)
[ -z "$realreadlink" ] && exiterr "the 'readlink' program is not installed on your system. $0 cannot be run!"
if ! readlink -f test >/dev/null 2>/dev/null; then
  readlink() {
    [ "$1" == "-f" ] && shift # skip to the next thing if we have "-f"
    path="$(cd $(dirname "$1");pwd)"
    rp=$($realreadlink "$path") # returns empty if not a link
    [ -z "$rp" ] && rp="$path"
    fullpath="$path/$(basename "$1")"
    echo "$fullpath"
  }
fi
Attachment: runROBEX.sh

Threaded View

TitleAuthorDate
runROBEX with BSD or OS X (readlink -f issue)
LabNuero CogDevel Jul 31, 2017
John Muschelli Sep 18, 2017