diff --git a/doitlive/keyboard.py b/doitlive/keyboard.py index 2671bb7..0d767dc 100644 --- a/doitlive/keyboard.py +++ b/doitlive/keyboard.py @@ -1,14 +1,15 @@ # -*- coding: utf-8 -*- import os +import shlex import subprocess from tempfile import NamedTemporaryFile import click from click import getchar -from doitlive.styling import echo, echo_prompt -from doitlive.termutils import raw_mode, get_default_shell from doitlive.compat import ensure_utf8 +from doitlive.styling import echo, echo_prompt +from doitlive.termutils import get_default_shell, raw_mode env = os.environ @@ -66,7 +67,8 @@ def write_commands(fp, command, args): def run_command(cmd, shell=None, aliases=None, envvars=None, test_mode=False): shell = shell or get_default_shell() - if cmd.startswith("cd "): + command_as_list = shlex.split(cmd) + if len(command_as_list) and command_as_list[0] == 'cd': cwd = os.getcwd() # Save cwd directory = cmd.split()[1].strip() if directory == '-': # Go back to $OLDPWD