Skip to content

Command line argument parsing fails if script name contains dash #423

@mvoelk

Description

@mvoelk
(venv) mmh-mv@pc:/$ tqdm
argv ['/home/mmh', 'mv/venv/bin/tqdm', '']
opts {'mv/venv/bin/tqdm': ''}

Error:
Usage:
  tqdm [--help | options]
^CTraceback (most recent call last):
  File "/home/mmh-mv/venv/lib/python3.5/site-packages/tqdm/_main.py", line 149, in main
    tqdm_args[o] = cast(v, opt_types[o])
KeyError: 'mv/venv/bin/tqdm'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mmh-mv/venv/lib/python3.5/site-packages/tqdm/_main.py", line 151, in main
    raise TqdmKeyError(str(e))
tqdm._tqdm.TqdmKeyError: "'mv/venv/bin/tqdm'"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mmh-mv/venv/bin/tqdm", line 11, in <module>
    sys.exit(main())
  File "/home/mmh-mv/venv/lib/python3.5/site-packages/tqdm/_main.py", line 155, in main
    for i in sys.stdin:
KeyboardInterrupt

I tried to fix RE_SHLEX = re.compile(r'\s*--?([^\s=]+)(?:\s*|=|$)') and quickly gave it up...

Is it an option to use the argparse module?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions