reitzig / sdkman-for-fish

Adds support for SDKMAN! to fish
MIT License
280 stars 13 forks source link

fix "stat: illegal option -- c" #28

Closed zhangwei closed 4 years ago

zhangwei commented 4 years ago

@reitzig

Hi, I am getting the issue with stat -c in MacOS 10.14.6. stat -c does not work normally

stat: illegal option -- c
usage: stat [-FlLnqrsx] [-f format] [-t timefmt] [file ...]

See https://github.com/phpbrew/phpbrew/issues/399

reitzig commented 4 years ago

It seems your commit would break it on Linux:

— ~ $ stat -c "%U" $SDKMAN_DIR
raphael
— ~ $ stat -f "%Su" $SDKMAN_DIR
stat: cannot read file system information for '%Su': No such file or directory
  File: "/home/raphael/.sdkman"
    ID: 721c61e23c37aed8 Namelen: 255     Type: ext2/ext3
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 229681641  Free: 223090890  Available: 211406257
Inodes: Total: 58408960   Free: 58250721

There should be a red test, my bad...

reitzig commented 4 years ago

I added a test on dev; please rebase your PR on that branch. We should see a failing test then. If you can make it pass, I'll consider it.

FWIW, I started a branch to work towards macOS compatibility (cf. issue #29). Contributions welcome.

zhangwei commented 4 years ago

@reitzig I rebased the PR. Does it seem that the test was passed?

BTW I noticed that you commit the commit 12f7d3d, and I think that should be a good solution for the issue.

reitzig commented 4 years ago

Thanks for your effort!

I see now that it won't be possible to write a failing test here: Fish simply can't separate "$owner != (whoami)" from "stat failed with an error", since both result in a non-zero exit code of test.

I'm closing this since a working fix exists on the upstream branch. Let's coordinate on #29 for getting sdk to macOS!