Mercurial > pyshada
changeset 12:a5699b110308
Update environment variable directory instead of string composing.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 29 Mar 2011 15:21:53 +0800 |
parents | d30e2253c3d6 |
children | 9f0d13830f6c |
files | shada/pysh.py |
diffstat | 1 files changed, 8 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/shada/pysh.py Tue Mar 29 01:30:00 2011 +0800 +++ b/shada/pysh.py Tue Mar 29 15:21:53 2011 +0800 @@ -50,14 +50,15 @@ server_addr = server.get_addr() ns['PYSHELL_SERVER'] = server_addr - esc = lambda x: str(x).replace('\\', '\\\\').replace('"', '\\"') - env = ';'.join(['export %s="%s"' % (k, esc(v)) - for k, v in ns.items() - if isinstance(v, (str, int, float))]) - pid = os.fork() - if pid == 0: - os.system(env + ';(' + cmd + ')| $py terminate_shell') + if pid == 0: # child + for key, value in ns.items(): + if isinstance(value, (str, int, float)): + os.environ[key] = str(value) + pass + pass + + os.system('(' + cmd + ')| $py terminate_shell') sys.exit(0) pass