whatwg / html-build

Build scripts for https://github.com/whatwg/html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

realpath doesn't exist on OSX

jakearchibald opened this issue · comments

But it can be installed via

brew install coreutils

Some good alternatives here... http://stackoverflow.com/q/3572030/3191

Of those http://stackoverflow.com/a/18443300/441757 looks like those most useful:

#!/bin/sh
realpath() {
  OURPWD=$PWD
  cd "$(dirname "$1")"
  LINK=$(readlink "$(basename "$1")")
  while [ "$LINK" ]; do
    cd "$(dirname "$LINK")"
    LINK=$(readlink "$(basename "$1")")
  done
  REALPATH="$PWD/$(basename "$1")"
  cd "$OURPWD"
  echo "$REALPATH"
}
realpath "$@"

I’ll open a PR with a patch that uses that instead.

OK I see now a complication is that the code is actually using realpath with --relative-to:

SOURCE_RELATIVE=$(realpath --relative-to=. $HTML_SOURCE

…so will also need to see if we can emulate that.

Apparently Ubuntu doesn't have --relative-to either... going to try a few fixes here.