Skip to content

Commit

Permalink
Handle spaces in executable paths
Browse files Browse the repository at this point in the history
Fixes #5
  • Loading branch information
adamws committed Apr 29, 2024
1 parent 01144e8 commit c3cb923
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions source/git.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import configparser
import os
import platform
import shlex
import subprocess
import sys
from pathlib import Path
from typing import Optional

Expand All @@ -23,10 +25,12 @@


def __run(command: str, cwd: Path) -> str:
args = f"{git} {command}"
if sys.platform != "win32":
args = shlex.split(args)
process = subprocess.Popen(
git + " " + command,
args,
cwd=cwd,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
Expand Down Expand Up @@ -57,7 +61,10 @@ def toplevel(path: Path) -> Optional[Path]:


def guitool(repo_dir: Path) -> None:
subprocess.Popen(git_gui, cwd=repo_dir, shell=True)
args = git_gui
if sys.platform != "win32":
args = shlex.split(args)
subprocess.Popen(args, cwd=repo_dir)


__all__ = ["version", "toplevel", "guitool"]

0 comments on commit c3cb923

Please sign in to comment.