mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-11 05:34:17 +00:00
Merge pull request #205 from Sighery/diff_command
Use alternative list-based diff_cmd escaping
This commit is contained in:
@@ -49,7 +49,7 @@ class Settings(DictParser):
|
|||||||
upignore=[], cmpignore=[], instignore=[],
|
upignore=[], cmpignore=[], instignore=[],
|
||||||
workdir='~/.config/dotdrop', showdiff=False,
|
workdir='~/.config/dotdrop', showdiff=False,
|
||||||
minversion=None, func_file=[], filter_file=[],
|
minversion=None, func_file=[], filter_file=[],
|
||||||
diff_command='diff -r "{0}" "{1}"'):
|
diff_command='diff -r {0} {1}'):
|
||||||
self.backup = backup
|
self.backup = backup
|
||||||
self.banner = banner
|
self.banner = banner
|
||||||
self.create = create
|
self.create = create
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import subprocess
|
|||||||
import tempfile
|
import tempfile
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
import shlex
|
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import inspect
|
import inspect
|
||||||
import importlib
|
import importlib
|
||||||
@@ -71,12 +70,19 @@ def shell(cmd, debug=False):
|
|||||||
|
|
||||||
|
|
||||||
def diff(original, modified, raw=True,
|
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"""
|
"""compare two files"""
|
||||||
if not diff_cmd:
|
if not diff_cmd:
|
||||||
diff_cmd = 'diff -r "{0}" "{1}"'
|
diff_cmd = 'diff -r {0} {1}'
|
||||||
cmd = diff_cmd.format(original, modified)
|
|
||||||
_, out = run(shlex.split(cmd), raw=raw, debug=debug)
|
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
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user