From f2474fa7f02fa2551c35154810cdc54a15df41d8 Mon Sep 17 00:00:00 2001 From: Mihai Moldovan Date: Mon, 30 May 2022 20:41:00 +0200 Subject: [PATCH] commandline: handle calls without arguments gracefully Fixes the following error: ``` % osc Traceback (most recent call last): File "/usr/bin/osc", line 45, in r = babysitter.run(osccli) File "/usr/lib/python3.10/site-packages/osc/babysitter.py", line 67, in run return prg.main(argv) File "/usr/lib/python3.10/site-packages/osc/cmdln.py", line 341, in main self.postoptparse() File "/usr/lib/python3.10/site-packages/osc/commandline.py", line 137, in postoptparse if self._get_canonical_cmd_name(self.args[0]) == "help": IndexError: list index out of range ``` --- osc/commandline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osc/commandline.py b/osc/commandline.py index 9180f925..2f7a4832 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -134,7 +134,7 @@ class Osc(cmdln.Cmdln): def postoptparse(self): """merge commandline options into the config""" - if self._get_canonical_cmd_name(self.args[0]) == "help": + if not self.args or self._get_canonical_cmd_name(self.args[0]) == "help": # avoid loading config that may trigger prompt for username, password etc. return