BBEdit diff:

I want a bbdiff command-line program. Something that will let me type:

bbdiff file1 file2

or

bbdiff dir1 dir2

to initiate a file comparison or multi-file comparison in BBEdit. Ideally, Bare Bones would include something like this along side the bbedit command-line tool, but I was wondering if anyone has created (or could easily create) such a tool via a Perl script making some AppleScript calls or something?
bbedit-compare.pl:

#!/usr/bin/perl

use warnings;
use strict;

use File::Spec::Unix;

my $file1 = shift or Usage();
my $file2 = shift or Usage();

compare_in_bbedit( $file1, $file2 );

sub Usage {
print STDERR "Usage: bbedit-compare.pl file1 file2\n";
exit( 1 );
}

sub compare_in_bbedit {
my( $file1, $file2 ) = @_;

$file1 = File::Spec::Unix->rel2abs( $file1 );
$file2 = File::Spec::Unix->rel2abs( $file2 );

do_osa_script( <<EOM );
tell app "BBEdit"
compare POSIX file "$file1" against POSIX file "$file2"
activate
end tell
EOM

}

sub do_osa_script {
my( $script ) = @_;

my $fh;
open( $fh, "| /usr/bin/osascript >/dev/null" ) or die "cant open osascript $!";
print $fh $script;
close( $fh );
}

Enjoy,
Peter.

--
<http://www.interarchy.com/> <http://download.interarchy.com/>

Reply via email to