Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The wrapper doesn't work on macOS #13

Closed
morozov opened this issue Oct 10, 2020 · 3 comments · Fixed by #17
Closed

The wrapper doesn't work on macOS #13

morozov opened this issue Oct 10, 2020 · 3 comments · Fixed by #17

Comments

@morozov
Copy link
Contributor

morozov commented Oct 10, 2020

readlink: illegal option -- f
usage: readlink [-n] [file ...]
usage: dirname path
readlink: illegal option -- f
usage: readlink [-n] [file ...]

Unlike GNU readlink where -f is:

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

In BSD readlink it's:

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

The dirname error is a side effect of that since readlink called on a non-link results in an empty string passed to dirname.

The wrapper would be more robust if it used set -e and quoted all variables:

set -e

PREPEND="$(readlink -f -- "$(dirname "$(readlink -f -- "$0")")/../src/prepend.php")"

Then at least it wouldn't try to call dirname with an empty value which is the result of the error in the subshell.

@weirdan
Copy link
Owner

weirdan commented Apr 10, 2021

I think it makes sense to use PHP instead. If it's not available the script won't work anyway.

@weirdan
Copy link
Owner

weirdan commented Apr 10, 2021

Something like

PREPEND="$(php -n -r 'echo realpath(dirname(realpath($argv[1])) . "/../src/prepend.php");' -- "$0")"

should do the trick I suppose.

@weirdan
Copy link
Owner

weirdan commented Apr 10, 2021

Fixed in 1.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants