Skip to content

Invalid git post-commit hook under Mac OSX Mountain Lion #1

Closed
veilleperso opened this Issue Mar 30, 2013 · 2 comments

2 participants

@veilleperso

When the hook run the following command
(git diff --name-only HEAD~ HEAD 2>/dev/null || git diff-tree -r --no-commit-id --name-only --root HEAD) | grep -P '^(Gemfile|Gemfile.lock|.*.gemspec|package.json|npm-shrinkwrap.json)$'

I've got the following error
usage: grep [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
[-e pattern] [-f file] [--binary-files=value] [--color=when]
[--context[=num]] [--directories=action] [--label] [--line-buffered]
[--null] [pattern] [file ...]

It seems that the default grep installed in mountain lion doesn't like the -P command

Replacing by -E seems to do the trick.

@gonzoyumo
Gemnasium member

Looks odd, your error message clearly mentions the -P option in "usage"...
We'll check this though, thanks for reporting it.

@veilleperso

Yes I know, it seems to be a bug in grep usage help of mountain lion, but Apple switched version of grep and doesn't provide -P option anymore:

Cf. http://www.dirtdon.com/?p=1452
and
https://www.google.com/?q=grep+mountain+lion+perl+regexp

@gonzoyumo gonzoyumo was assigned Apr 2, 2013
@gonzoyumo gonzoyumo added a commit that closed this issue Apr 2, 2013
@gonzoyumo gonzoyumo Drop Perl regexp style for compatibility
 * closes #1
63a5173
@gonzoyumo gonzoyumo closed this in 63a5173 Apr 2, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.