emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [elpa] master 8650a52 2/2: Issue #18: files considered different if


From: Alexey Veretennikov
Subject: Re: [elpa] master 8650a52 2/2: Issue #18: files considered different if they have different sizes
Date: Mon, 26 Dec 2016 18:03:23 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (darwin)

Thanks! I'll experiment with process-file.

Stefan Monnier <address@hidden> writes:

>> +         (diff-cmd (concat diff-command " -q" " "
>> +                           (ztree-quotify-string file1-untrampified)
>> +                           " "
>> +                           (ztree-quotify-string file2-untrampified))))
>> +    (if (and
>> +         (= (nth 7 (file-attributes file1-untrampified))
>> +            (nth 7 (file-attributes file2-untrampified)))
>> +         (> (length (shell-command-to-string diff-cmd)) 2))
>
> The function `process-file` should be able to do a better job than
> shell-command-to-string (among other things, no need for "quotify").
>
> You'll probably want to run it something like
>
>     (let* ((file1 (file-name-directory (expand-file-name file1)))
>            (file2 (file-name-directory (expand-file-name file2)))
>            (default-directory (file-name-directory file1))
>            (file1 (file-relative-name file1))
>            (file2 (file-relative-name file2))
>            (exit-code
>             (process-file diff-command nil nil nil
>                           "-q" file1 file2)))
>       (if (and (numberp exit-code) (= exit-code 0))
>           'same 'diff))
>
> BTW, a file with name
>
>    hello"; rm -rf ~/.
>
> will probably not do what you wanted.  Using process-file should fix
> this problem since it doesn't need to quote anything.  But if you insist
> on using a shell command, then just use shell-quote-argument instead of
> ztree-quotify-string.
>
>
>         Stefan

-- 
Br,
/Alexey



reply via email to

[Prev in Thread] Current Thread [Next in Thread]