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

jd-cli script does not work on OSX/macOS #50

Open
stiemannkj1 opened this issue Mar 31, 2021 · 2 comments
Open

jd-cli script does not work on OSX/macOS #50

stiemannkj1 opened this issue Mar 31, 2021 · 2 comments

Comments

@stiemannkj1
Copy link

stiemannkj1 commented Mar 31, 2021

Reproduced on macOS Mojave 10.14.6

Steps to reproduce:

  1. Download jd-cli and unzip it.
  2. Add ~/Downloads/jd-cli-1.2.0-dist to your unix PATH.
  3. Navigate to another directory (for example: cd ..).
  4. Attempt to decompile any class or jar:
    jd-cli ~/Test/Main.class

If the bug still exists jd-cli will fail to decompile the class and show the following error:

$ jd-cli ~/Test/Main.class
readlink: illegal option -- e
usage: readlink [-n] [file ...]
Error: Unable to access jarfile /home/me/jd-cli.jar

If the bug is fixed, jd-cli will decompile the class without any error message.

Workarounds/Fixes

In the jd-cli shell script, replace the first line which uses readlink with Dave Dopson's solution from StackOverflow:

DIRNAME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

Or if you aren't using bash:

DIRNAME="$( cd "$( dirname "$0" )" &> /dev/null && pwd )"

This workaround might also be the correct fix for this problem unless you need to worry about symbolic links, in which case, you'll need to use one of the more complex solutions from StackOverflow:

@stiemannkj1 stiemannkj1 changed the title jd-cli script does not work on OSX jd-cli script does not work on OSX/macOS Mar 31, 2021
@kay-22
Copy link

kay-22 commented Jun 9, 2022

In case you need to worry about symbolic links, there is a simple workaround. Replace the first line with:

DIRNAME=$(dirname $(realpath $(which jd-cli)))

Notice that you need realpath which you can install with the coreutils package:

brew install coreutils

@kwart
Copy link
Member

kwart commented Jun 9, 2022

The realpath is not an option here, as we want a minimum of the deps. Both Linux and Mac users would need to install additional software to make the script working.

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

No branches or pull requests

3 participants