Skip to content

Commit

Permalink
Use shlex.split for tokenizing command
Browse files Browse the repository at this point in the history
  • Loading branch information
sloria committed May 12, 2018
1 parent 47ec3e1 commit a387b72
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions doitlive/keyboard.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a387b72

Please sign in to comment.