Skip to content

Commit

Permalink
Merge pull request #7908 from ThomasWaldmann/fix-inv-pattern-errorhan…
Browse files Browse the repository at this point in the history
…dling-master

Fix arg parsing error handling (master)
  • Loading branch information
ThomasWaldmann committed Nov 5, 2023
2 parents 1f48e50 + 77cf77e commit b246e30
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/borg/archiver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,17 @@ def main(): # pragma: no cover
tb = format_tb(e)
print(tb, file=sys.stderr)
sys.exit(e.exit_code)
except argparse.ArgumentTypeError as e:
# we might not have logging setup yet, so get out quickly
print(str(e), file=sys.stderr)
sys.exit(EXIT_ERROR)
except Exception:
msg = "Local Exception"
tb = f"{traceback.format_exc()}\n{sysinfo()}"
# we might not have logging setup yet, so get out quickly
print(msg, file=sys.stderr)
print(tb, file=sys.stderr)
sys.exit(EXIT_ERROR)
try:
with sig_int:
exit_code = archiver.run(args)
Expand Down
2 changes: 1 addition & 1 deletion src/borg/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def parse_inclexcl_command(cmd_line_str, fallback=ShellPattern):

cmd = cmd_prefix_map.get(cmd_line_str[0])
if cmd is None:
raise argparse.ArgumentTypeError("A pattern/command must start with anyone of: %s" % ", ".join(cmd_prefix_map))
raise argparse.ArgumentTypeError("A pattern/command must start with any of: %s" % ", ".join(cmd_prefix_map))

# remaining text on command-line following the command character
remainder_str = cmd_line_str[1:].lstrip()
Expand Down

0 comments on commit b246e30

Please sign in to comment.