Menu

#95 diff against '/dev/null' failes

V5.6
closed-fixed
None
5
2023-10-07
2023-10-06
rob m
No

when viewing a diff against a new or deleted file some tools provide /dev/null as the file to compare against. tkdiff as of version 4.2 used to support this mode but as of version 5.6 fails with:

Error: '/dev/null' exists, but is not a file
Error: Insufficient usable input
TkDiff Aborted

to reproduce:
tkdiff /dev/null any_file

note: this prevents things like git difftool from showing new or deleted files.

this hacky patch fixes the problem.

diff -u old/tkdiff new/tkdiff
--- old/tkdiff  2023-10-06 00:00:33.163905714 -0700
+++ new/tkdiff  2023-10-06 00:00:22.483585031 -0700
@@ -2121,7 +2119,7 @@
     } elseif {!$tildechk} {
         # DO NOT REPORT non-existence if this attempt was ONLY a probe
         if {$probe} { return 1 } { set MSG "File '$fn' does not exist" }
-    } elseif {[file isfile $fn]} {
+    } elseif {[file isfile $fn] || "$fn" == "/dev/null"} {
         set finfo(${A}lbl,$ndx) [shortNm [set finfo(${A}pth,$ndx) "$fn"]]
     } else { set MSG "'$fn' exists, but is not a file" }

Discussion

  • rob m

    rob m - 2023-10-06

    Ubuntu 22.04.3 LTS x64

     
  • michael-m

    michael-m - 2023-10-07
    • status: open --> closed-fixed
    • assigned_to: michael-m
     
  • michael-m

    michael-m - 2023-10-07

    Fair enough.
    While it seems a bit tedious to go to the trouble of running diff just to prove whats readily known, I agree the operational disruption (aborting) could be annoying. However, your suggested patch needs to handle more than just a Unix-like world (eg. "nul" on a Windows platform). As its likely you've already adjusted your own copy (having diagnosed the problem), the official fix will be available in an upcoming release (whenever that next occurs). Thanks for reporting the issue.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.