alphapapa/org-protocol-capture-html

./org-protocol-capture-html.sh not parsing argument correctly

Closed this issue · 3 comments

For example, ./org-protocol-capture-html.sh --help doesn't show the help message then quit as I expect. Instead, it runs something like

emacsclient org-protocol://capture-html?template=w&url=http%3A%2F%2Fexample.com%0A&title=%20%0A&body=.%2Forg-protocol-capture-html.sh%20-o%20dh%3Art%3Au%3A%20-l%20debug%2Chelp%2Cheading%3A%2Creadability%2Ctemplate%3A%2Curl%3A%20--%20--help%0A

My system is macOS, I have tried both bash 3.2.57 and 4.4.12. And according to man getopt, the getopt I am using is from the BSD. I heard that BSD programs often don't support long options, though I am not sure this is related.

Any tips?

Hi,

Thanks for reporting this. I suspect that the problem is indeed the getopt implementation. Mine's man page says:

The getopt command is part of the util-linux package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/

You might be able to find a compatible implementation in Homebrew, but I know very little about it so I can't offer specific advice there.

I guess a more portable solution would be to use getopts from Bash instead, but it's not as nice to use; that's why I prefer getopt. But I didn't realize OS X had a different implementation.

Let me know if you find anything in Homebrew or some other solution. If there's no other way around it, I guess we can use getopts instead (although no promises about when I will get around to changing it ;) ). I don't think many people use the script, so I guess that's why this wasn't noticed sooner.

Thanks.

Oh, I see. I installed getopt from util-linux manually then the issue is solved. (I use MacPorts as my package manager, it does provide util-linux but it doesn't install getopt on purpose, it only installs a small subset of util-linux).

Great! I'll add a note to the readme and a message to the script to try to catch cases like this. Thanks.