Showing posts with label diff. Show all posts
Showing posts with label diff. Show all posts

Saturday, 9 January 2010

Not so "diff"-icult after all

I've gone back and updated the way that the filename formatter would work on the command line, and it turns out that on the command line, it's a lot simpler than I'd previously thought.  So here's the ammended version:

perl -e 'print join("\\ ", @ARGV)' [FILE NAME]
I also feel no shame in using yet another "diff" based pun in the title.


Friday, 8 January 2010

A "diff"-icult problem

Sorry, I couldn't help myself.

Writing the file copying routines for the "diff for folders", I've come across the small problem of converting from the non-escaped versions of file names that readdir produces, to the escaped versions that the shell commands need.  I have, however, managed to produce a imho pretty nice oneliner to do this.
join("\\ ", split(/ /, $fileName));
 Which takes a file name like "some random file.txt" and converts it to "some\ random\ file.txt". Obviously, this won't work directly from the command line yet, but when I've got more time I'm going to adapt it to do so.

Tuesday, 5 January 2010

Creating a "diff" for folders

For me, diff is one of those utilities that, although I don't use it frequently, I would be lost without.  In essence, diff checks the content of two files and compares them line by line; showing you where there are differences between the two.

Now unfortunately, diff is also one of those utilities that suffers from Unix-itis, the tendency for a command line utility to have an interface that could charitably be described as esoteric (I could cite awk and sed here but I won't). Getting diff to show he difference between the content of two directories is an "interesting" problem, as this page shows.  Comparing the content of two folders though is actually one of those problems that personally occurs quite often.  Therefore I've decided to write my own program, to perform this task automatically.

Now, as usual, I've decided to write the program in perl, and have managed to put together a working prototype, but there is still work that needs to be done.  I've gone with a GUI for the interface design, but want to put in command line options as well.  Over the course of the next few days, I'm planning to solve the few bugs and glitches the prototype has, as well as add increased functionality, and stability.