I have the following function in script.py utlizing Python click library:
@click.command()
@click.argument('some-arg', nargs=-1)
def main(some_arg):
print(some_arg)
main()
The above function gets an unlimited number of command line arguments and prints them - works as expected:
python3 script.py my unlimited CLI args
outputs
('my', 'unlimited', 'CLI', 'args')
However, trying to pass arguments with ( or ) in them results in a bash syntax error:
python3 script.py these are some more arguments (123)
bash: syntax error near unexpected token `('
Is there any way I can pass an argument containing the ( or ) signs without receiving a bash syntax error ?
I know I can wrap it with quotations but this will result in a single string argument being passed. Also, I'm getting my input elsewhere and don't want to tamper with it all that much so wrapping with quotations is kind of a last resort.
(is a special character in Bash and needs to be quoted or escaped to be treated literally.clickproblem.(number).