diff mbox series

[1/1] tools: efivar.py without arguments

Message ID 20210109005557.10805-1-xypron.glpk@gmx.de
State Accepted, archived
Commit 4f6ec7754b1342ae9f9df4524fa9fa45299f3d68
Delegated to: Heinrich Schuchardt
Headers show
Series [1/1] tools: efivar.py without arguments | expand

Commit Message

Heinrich Schuchardt Jan. 9, 2021, 12:55 a.m. UTC
When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
  File "tools/efivar.py", line 380, in <module>
    main()
  File "tools/efivar.py", line 360, in main
    args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 tools/efivar.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--
2.29.2

Comments

Paulo Alcantara Jan. 11, 2021, 2:12 p.m. UTC | #1
Heinrich Schuchardt <xypron.glpk@gmx.de> writes:

> When tools: efivar.py is called without arguments an error occurs:
>
> Traceback (most recent call last):
>   File "tools/efivar.py", line 380, in <module>
>     main()
>   File "tools/efivar.py", line 360, in main
>     args.func(args)
> AttributeError: 'Namespace' object has no attribute 'func'
>
> Show the online help if the arguments do not specify a function.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  tools/efivar.py | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
diff mbox series

Patch

diff --git a/tools/efivar.py b/tools/efivar.py
index ebfcab2f0a..c40a0fa6c7 100755
--- a/tools/efivar.py
+++ b/tools/efivar.py
@@ -357,7 +357,10 @@  def main():
     signp.set_defaults(func=cmd_sign)

     args = ap.parse_args()
-    args.func(args)
+    if hasattr(args, "func"):
+        args.func(args)
+    else:
+        ap.print_help()

 def group(a, *ns):
     for n in ns: