Blob Blame History Raw
From d6cbd130101add28431bd6e67aa2ea0430a9234e Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 11 Sep 2019 22:25:57 +0100
Subject: [PATCH 1/3] nbdsh: Fix behaviour of globals.

https://stackoverflow.com/a/11754346
---
 python/nbdsh.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/python/nbdsh.py b/python/nbdsh.py
index bb0db64..553e632 100644
--- a/python/nbdsh.py
+++ b/python/nbdsh.py
@@ -57,8 +57,10 @@ help (nbd)                          # Display documentation
     if not args.command:
         code.interact (banner = banner, local = locals(), exitmsg = '')
     else:
+        # https://stackoverflow.com/a/11754346
+        d = dict (locals(), **globals())
         for c in args.command:
             if c != '-':
-                exec (c)
+                exec (c, d, d)
             else:
-                exec (sys.stdin.read ())
+                exec (sys.stdin.read (), d, d)
-- 
2.23.0