Apr-03-2024, 06:57 PM
(This post was last modified: Apr-03-2024, 06:58 PM by Gribouillis.)
(Apr-03-2024, 03:38 PM)kaustin Wrote: How do I pass my parameters as needed?I think it is a bash question instead of a python question. It seems to me that you only need to add quotes around your variables, for example in my bash terminal
Output:λ foo='hello world'
λ bar="an argument with many spaces"
λ echoargs "$foo" "$bar"
['/home/eric/bin/echoargs', 'hello world', 'an argument with many spaces']
λ echoargs $foo $bar
['/home/eric/bin/echoargs', 'hello', 'world', 'an', 'argument', 'with', 'many', 'spaces']
Here echoargs
is a Python script that only prints the arguments that it receives. As you can see, in the first invocation with double quotes "$foo"
the shell handles correctly hello world
as a single argument, but when I don't use the double quotes, it treats it as two arguments.Python has nothing to do with this problem because it only receives the arguments that were processed by the shell.
« We can solve any problem by introducing an extra level of indirection »