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

Setting default device option on --enable doesn't wrap device in quotation marks #295

Open
jegtnes opened this issue Mar 9, 2016 · 1 comment

Comments

@jegtnes
Copy link

jegtnes commented Mar 9, 2016

Hey folks! Thanks a lot for lolcommits. ❤️ It's been fun gradually watching my descent into madness over the course of various projects.

Just wanted to report a thing that's been a very mild inconvenience: When enabling lolcommits for a new repository using --enable, it doesn't wrap the option in quotation marks as it should.

Input:
lolcommits --enable --device="FaceTime HD Camera"

Expected output (.git/hooks/post-commit)

#!/bin/sh
### lolcommits hook (begin) ###
if [ ! -d "$GIT_DIR/rebase-merge" ]; then
export LANG="en_GB.UTF-8"
export PATH="/Users/alex/.rbenv/versions/2.2.2/bin:/usr/local/bin:$PATH"
lolcommits --capture --device="FaceTime HD Camera"
fi
###  lolcommits hook (end)  ###

Actual output (.git/hooks/post-commit):

#!/bin/sh
### lolcommits hook (begin) ###
if [ ! -d "$GIT_DIR/rebase-merge" ]; then
export LANG="en_GB.UTF-8"
export PATH="/Users/alex/.rbenv/versions/2.2.2/bin:/usr/local/bin:$PATH"
lolcommits --capture --device=FaceTime HD Camera
fi
###  lolcommits hook (end)  ###

This causes my captures to fail by default if multiple webcams are connected, as the device just sets to FaceTime:
Device "FaceTime" not found - aborting

I'd love to submit a pull request for this, but I'm a bit worried as my Ruby skillz are very rusty and wanted to make sure I get this right and do things the Ruby way. Could you possibly point me in the right direction?

Taking an educated guess, this bug might happen around here, where the hook is installed and the arguments are passed. From some quick googling it looks like this issue is down to the shell swallowing the quotation marks, so the sensible option could be to escape all the arguments. This may also fix edge cases like webcams having device names with other unescaped characters rather that aren't a space.

If I'm right in my assumptions (and please do let me know if I'm wrong!), what'd be a good Ruby-like way to escape these strings, and how is the best way to run this gem locally for testing purposes?

In any case, here's to hoping I won't end up like this:

c8129353169

@jegtnes jegtnes changed the title Setting default device option on --enable doesn't embed wrap device in quotation marks Setting default device option on --enable doesn't wrap device in quotation marks Mar 9, 2016
@matthutchinson
Copy link
Member

Thanks for spotting this, it is indeed an issue, and you're correct that is the place where the args are expanded into the commit hook from the --enable command.

I might get a chance to issue a fix for this at the weekend, if not there are some instructions on how to contribute here.

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

2 participants