맥에서 가끔 특정명령을 실행시킬 경우 readlink: illegal option –f 라는 에러가 발생되는 경우가 있습니다. GNU 에서 만든 유틸을 맥에서 사용하는 경우 종종 이와 같은 오류가 발생하는데요.
greadlink 라는 유틸을 대체하여 사용하면 해결 하면 됩니다.
❯ greadlink --help
Usage: greadlink [OPTION]... FILE...
Print value of a symbolic link or canonical file name
-f, --canonicalize canonicalize by following every symlink in
every component of the given name recursively;
all but the last component must exist
-e, --canonicalize-existing canonicalize by following every symlink in
every component of the given name recursively,
all components must exist
-m, --canonicalize-missing canonicalize by following every symlink in
every component of the given name recursively,
without requirements on components existence
-n, --no-newline do not output the trailing delimiter
-q, --quiet
-s, --silent suppress most error messages (on by default)
-v, --verbose report error messages
-z, --zero end each output line with NUL, not newline
--help display this help and exit
--version output version information and exit
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report readlink translation bugs to <https://translationproject.org/team/>
Full documentation at: <https://www.gnu.org/software/coreutils/readlink>
or available locally via: info '(coreutils) readlink invocation'
설정 방법은
- brew 를 이용하여 coreutils 를 설치합니다.
❯ brew install coreutils
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core, caskroom/cask).
==> Updated Formulae
dhall-json diff-pdf monero pdftoedn pdftoipe pgloader poppler
==> Downloading https://homebrew.bintray.com/bottles/coreutils-8.29.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring coreutils-8.29.high_sierra.bottle.tar.gz
==> Caveats
All commands have been installed with the prefix 'g'.
If you really need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
Additionally, you can access their man pages with normal names if you add
the "gnuman" directory to your MANPATH from your bashrc as well:
MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH"
==> Summary
🍺 /usr/local/Cellar/coreutils/8.29: 430 files, 8.9MB
~ 51s
- greadlink 파일이 설치되었는지 확인 합니다.
❯ which greadlink
/usr/local/bin/greadlink
- readlink 명령 실행시 greadlink 가 실행 될 수 있도록 심볼릭 링크를 설정 합니다.
❯ ln -s "$(which greadlink)" "$(dirname "$(which greadlink)")/readlink"