fixed terminal encoding bug with exec

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2009-08-20 00:27:39 -04:00
parent 72bdc0915a
commit 9840cb4806
1 changed files with 11 additions and 6 deletions

View File

@ -25,10 +25,15 @@ class Exec(Method):
if bufname is None: bufname = '*%s*' % self.name.title()
if cmdname is None: cmdname = cmd.split(None, 1)[0]
p = Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
output = p.stdout.read()
result = p.wait()
status = os.WEXITSTATUS(result)
p = Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
output = p.stdout.read()
result = p.wait()
status = os.WEXITSTATUS(result)
try:
output2 = output.decode('utf-8')
except:
output2 = output.decode('latin-1')
if not os.WIFEXITED(result) or status != 0:
err = True
@ -37,9 +42,9 @@ class Exec(Method):
err = False
msg = "exec(%r): ok" % (cmdname,)
if output:
if output2:
switch_to = err or self.show_success
w.application.data_buffer(bufname, output, switch_to=switch_to)
w.application.data_buffer(bufname, output2, switch_to=switch_to)
w.set_error(msg)
def _execute(self, w, **vargs):