1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-05 05:04:43 +00:00

Merge pull request #205 from Sighery/diff_command

Use alternative list-based diff_cmd escaping
This commit is contained in:
deadc0de
2020-01-26 19:41:17 +01:00
committed by GitHub
2 changed files with 12 additions and 6 deletions

View File

@@ -49,7 +49,7 @@ class Settings(DictParser):
upignore=[], cmpignore=[], instignore=[],
workdir='~/.config/dotdrop', showdiff=False,
minversion=None, func_file=[], filter_file=[],
diff_command='diff -r "{0}" "{1}"'):
diff_command='diff -r {0} {1}'):
self.backup = backup
self.banner = banner
self.create = create

View File

@@ -9,7 +9,6 @@ import subprocess
import tempfile
import os
import uuid
import shlex
import fnmatch
import inspect
import importlib
@@ -71,12 +70,19 @@ def shell(cmd, debug=False):
def diff(original, modified, raw=True,
diff_cmd='diff -r "{0}" "{1}"', debug=False):
diff_cmd='diff -r {0} {1}', debug=False):
"""compare two files"""
if not diff_cmd:
diff_cmd = 'diff -r "{0}" "{1}"'
cmd = diff_cmd.format(original, modified)
_, out = run(shlex.split(cmd), raw=raw, debug=debug)
diff_cmd = 'diff -r {0} {1}'
replacements = {
"{0}": original,
"{original}": original,
"{1}": modified,
"{modified}": modified,
}
cmd = [replacements.get(x, x) for x in diff_cmd.split()]
_, out = run(cmd, raw=raw, debug=debug)
return out