michalrus / git-hooks-code-autoformat

Apache License 2.0
87 stars 24 forks source link

Cann't use on mac os system #6

Closed brightgong closed 6 years ago

brightgong commented 8 years ago

I use this hook on my mac and it didn't work when i done everything written in README step by step.
The error is: find: -executable: unknown primary or operator

did i make mistake on somewhere?

rvvincelli commented 8 years ago

In the ejf binary sed -re is invoked, but the BSD-style should be sed -Ee. Anyway I get a runtime exception in the main when running the formatter directly from the command line.

alxpgr commented 8 years ago

The problem is that -executable is GNU specific. This thread on StackExchange gives the alternative that should work in both systems. I tried this change and the change for sed as indicated by @rvvincelli and it works on my mac. I haven't been able to test it on a Linux machines though.

michalrus commented 7 years ago

Would any of you care to submit a PR, that works on both systems, GNU, and the other one? :grin:

tianheng commented 6 years ago

a quick fix:

  1. vim git-hooks/tools/eclipse-java-formatter/ejf
  2. modify sed -re to sed -Ee
michalrus commented 6 years ago

I see in the GNU sed’s manual:

     -E, -r, --regexp-extended

          use  extended regular  expressions in  the script  (for
          portability use POSIX -E).

… so we can just switch to -Ee everywhere.

michalrus commented 6 years ago

Since I don’t have a non-GNU system to test, it would be optimal if someone else did a PR, but here it goes:

michalrus commented 6 years ago

(And that -executable bit was fixed in #10.)