diff --git a/method/shell.py b/method/shell.py index 2ebd83f..5b37fed 100644 --- a/method/shell.py +++ b/method/shell.py @@ -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):