Install fails on Mac (no option -e for readlink) #38

Closed
Gaffney opened this Issue Dec 29, 2014 · 8 comments

3 participants

@Gaffney

There is no -e option on the readlink installed on Mac OSX, so the install fails completely (see L11 on install here)

bash-3.2$ sh /Users/me/.antigen/repos/https-COLON--SLASH--SLASH-github.com-SLASH-tarruda-SLASH-zsh-autosuggestions.git/install
readlink: illegal option -- e
usage: readlink [-n] [file ...]
usage: dirname path

Setup completed successfully!

Refer to this commit: 32fb793

@faceleg faceleg added the bug label Jan 4, 2015
@faceleg faceleg closed this in 89b85d8 Jan 8, 2015
@Gaffney

@faceleg I don't think this fixes it. Compare the Linux readlink -f to the Mac version:

Linux

-f, --canonicalize
    canonicalize by following every symlink in every component
    of the given name recursively; all but the last component must exist

Mac

-f format
    Display information using the specified format.  
    See the FORMATS section for a description of valid formats.

See also:

@faceleg

Thanks, reopening.

Seeing as you have quick access to a mac (I assume), would you mind fixing this?

@faceleg faceleg reopened this Jan 8, 2015
@Gaffney

I thought about it for a bit and I could not think of a clean fix, as installing coreutils is not a viable option. (That is what I did to fix it locally).

Can possibly think about it / fix it later this week or next when I am not so busy.

@faceleg

We could use something like:

SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
  DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  SOURCE="$(readlink "$SOURCE")"
  [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

From http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in

@bfred-it

@faceleg's code seems to work for me (OSX 10.10)

@Gaffney

@bfred-it Are you referring to what was committed or the script above?

@bfred-it

Script above my comment

@Gaffney

Cool, can you make a PR with your install file?

@faceleg faceleg closed this in #40 Jan 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment