def on_done(self, cwd, cmd_str):
        cmd = parse_cmd(cmd_str)
        if not cmd['input'] and cmd['output'] == '|':
            sublime.error_message(
                "Piping output to the view requires piping input from the view as well."
                + " Please use a preceding |.")
            return

        active_view = self.window.active_view()
        if cmd['input'] or cmd['output'] == '|':
            if not active_view:
                sublime.error_message(
                    "A view has to be active to pipe text from and/or to a view.")
                return

        settings = cmd_settings(cmd['shell_cmd'])

        before, after = settings['surround_cmd']
        shell_cmd = before + cmd['shell_cmd'] + after

        if cmd['input']:
            input_regions = [sel for sel in active_view.sel() if sel.size() > 0]
            if len(input_regions) == 0:
                input_regions = [sublime.Region(0, active_view.size())]
        else:
            input_regions = None


        # We can leverage Sublime's (async) build systems unless we're
        # redirecting the output into a view. In that case, we use Popen
        # synchronously.
        if cmd['output']:
            for region in (input_regions or [None]):
                self.process_region(active_view, region, cwd, shell_cmd, cmd['output'])
        else:
            if input_regions:
                # Since Sublime's build system doesn't support piping to STDIN
                # directly, use a tempfile.
                text = "".join([active_view.substr(r) for r in input_regions])
                temp = tempfile.NamedTemporaryFile(delete=False)
                temp.write(text.encode('utf8'))
                shell_cmd = (shell_cmd, pipes.quote(temp.name)) % "%s < %s"
            exec_args = settings['exec_args']
            exec_args.update({'cmd': shell_cmd, 'shell': True, 'working_dir': cwd})

            self.window.run_command("exec", exec_args)
dataset/ETHPy150Open misfo/Shell-Turtlestein/shell_turtlestein.py/ShellPromptCommand.on_done/swapped operands of `%`