Skip to content

Commit b832b96

Browse files
authored
v.util: improve detection for opendiff when automatically searching difftools (#21241)
1 parent 056a443 commit b832b96

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

vlib/v/util/diff/diff.v

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ pub fn find_working_diff_command() !string {
1919
'code', 'code.cmd']
2020
// NOTE: code.cmd is the Windows variant of the `code` cli tool
2121
for diffcmd in known_diff_tools {
22-
if diffcmd == 'opendiff' { // opendiff has no `--version` option
23-
if opendiff_exists() {
24-
return diffcmd
25-
}
26-
continue
22+
if diffcmd == 'opendiff' {
23+
os.find_abs_path_of_executable('opendiff') or { continue }
24+
return diffcmd
2725
}
2826
$if freebsd || openbsd {
2927
if diffcmd == 'diff' { // FreeBSD/OpenBSD diff have no `--version` option
@@ -51,20 +49,6 @@ pub fn find_working_diff_command() !string {
5149
return error('No working "diff" command found')
5250
}
5351

54-
// determine if the FileMerge opendiff tool is available
55-
fn opendiff_exists() bool {
56-
o := os.execute('opendiff')
57-
if o.exit_code < 0 {
58-
return false
59-
}
60-
if o.exit_code == 1 { // failed (expected), but found (i.e. not 127)
61-
if o.output.contains('too few arguments') { // got some expected output
62-
return true
63-
}
64-
}
65-
return false
66-
}
67-
6852
pub fn color_compare_files(diff_cmd string, file1 string, file2 string) string {
6953
if diff_cmd != '' {
7054
mut full_cmd := '${diff_cmd} --minimal --text --unified=2 --show-function-line="fn " ${os.quoted_path(file1)} ${os.quoted_path(file2)} '

0 commit comments

Comments
 (0)