0

For diff command, an exit status of 0 means no differences were found, 1 means some differences were found.

What are the error exit values for diff?

It works as expected with diff command.

However, when I try the same with vimdiff command, it doesn't work.

vimdiff -c "set foldlevel=9999" file1.log file2.log -c TOhtml -c  'w! 'vimdiff.html'' -c 'qa!'

Even though file1 and file2 are different here, echo $? returns 0. For diff, it returns 1 successfully as the files are different.

Is there a way I can do the same for vimdiff? How can I know whether the files were same or different for the above vimdiff command?

AutoTester999
  • 528
  • 1
  • 6
  • 25
  • 1
    But why would you want to use `vmdiff` which is not designed to work that way instead of `diff` which does exactly as required? – kaylum Jun 28 '20 at 03:07
  • vimdiff has features to output colored diff with side-by-side comparison which i can easily port to an html file. – AutoTester999 Jun 28 '20 at 03:09
  • 1
    Can you use `mydiff=$(vimdiff ...); if [ -n "${mydiff}" ]; then ...` ? – Walter A Jun 28 '20 at 08:53
  • 2
    I did some thinking and research on this one and I can't come up with anything good unless you want to be writing Vimscript. Personally, I would just run a second `diff` command. – Soren Bjornstad Jun 29 '20 at 01:53

0 Answers0