0

Env:

python3.7
OptionParser with a option [ add_option('-t', '--target', action='append', dest='targets') ]
OS: CentOS7.6

Problem:

So I am using this option to input a list of targets, and with this command line:
parser -t logs* -t test
there's a file "logs.tar.gz" in where I execute this command line, when i print the value of targets, this is what i get:
['logs.tar.gz', 'test']
So I believe this is a 'problem' of system level, and what I want to know is:
is there any way to make logs* be logs* without input logs\* in python?

miken32
  • 42,008
  • 16
  • 111
  • 154
Snart
  • 54
  • 6

1 Answers1

1

The shell is who is expanding the *. There is nothing that python can do here since it never gets to know about the log*.

You can force your shell to interpret the * as a literal value with some quoting:

parser -t "logs*" -t test

This works in zsh, it might be different for your shell.

rdas
  • 20,604
  • 6
  • 33
  • 46
  • you are right, looks like for centos i have to use literal string as the option! Thank you! – Snart Jun 05 '20 at 05:41