-
Notifications
You must be signed in to change notification settings - Fork 1
When arguments are passed to script via $@ in bash script, quoted parameters like --author get truncated #11
Comments
It's a good idea to handle this though. If you have the time to take care of this, it would be greatly appreciated! Otherwise, I'll look into it asap. Also, thanks for your contribution so far! |
@jf-ct , what python version are you running? I tried the following to reproduce the issue you mentioned, but I think it may have been already taken care of in newer versions of python. Shell script: #!/usr/bin/env bash
# Relay all flags given to this script to python using "@$"
python patchset-created "$@" patchset-created file #!/usr/bin/python3
import sys
from gerrit_hooks import parse_options
print(sys.argv)
options = parse_options()
print(options.uploader) Output: (tests-2UXd7nDr) nls@nls-ThinkPad-X270:~/repos/gerrit-hooks/tests$ bash arg_proxy.sh --uploader "me" --change 1
['patchset-created', '--uploader', 'me', '--change', '1']
me
(tests-2UXd7nDr) nls@nls-ThinkPad-X270:~/repos/gerrit-hooks/tests$ So either my test case is too simple, or it's already fixed. As for the tweaks, I updated the |
Hi Nils,
I'm using Python 3, but I think the key here is that your --uploader is a single block of word characters. What if you used a value like "John Doe <[email protected]>" instead? (this is the kind of value that Gerrit will pass to these hooks)
|
I would also note that for the |
One thing I forgot, when the value "John Doe [email protected]" gets passed by Gerrit, it seemed like it wasn't passing it with quotes |
Ah, okay! If it isn't passed with quotes, that would be an issue concerning the |
This may not be a bug in the library, but it may be possible to set
nargs="+"
and then have some logic to do a' '.join(gerrit_args.author)
(and so on for similar fields)So far I have had to do a workaround after parsing (using sys.argv) for the following fields:
--uploader
--change-owner
--author
Another similar issue occurs when Gerrit passes
--topic
without any argument, and the parser expects one to be there. (i.e. some of the configurations could be tweaked for certain options)Maybe instead of
_generate_parser()
there could be an extra step before that like_generate_options()
so that the options could be modified before the call to_generate_parser()
The text was updated successfully, but these errors were encountered: