#! /usr/bin/perl #--------------------------------------------------------------------- # $Id: eack.pl 1964 2008-02-25 00:31:57Z cjm $ # Copyright 2008 Christopher J. Madsen # # This program is free software; you can redistribute it and/or modify # it under the same terms as Perl itself. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the # GNU General Public License or the Artistic License for more details. # # Run ack under Emacs #--------------------------------------------------------------------- use strict; use File::Spec; pop @ARGV if lc $ARGV[-1] eq lc File::Spec->devnull; unshift @ARGV, qw(--nocolor --nogroup); close STDIN; # Otherwise ack might try to read from it # Decide what ack may be called: my @scripts = qw(ack ack-standalone); if ($^O eq 'MSWin32') { foreach (@scripts) { $_ .= '.bat' } } # Find ack and run it: foreach my $dir (File::Spec->path) { foreach my $script (@scripts) { my $ack = File::Spec->catfile($dir, $script); next unless -e $ack; print "$ack @ARGV\n"; do $ack; die $@ if $@; die "Couldn't run $ack: $!"; # Ack doesn't return, it calls exit } } die "Couldn't find ack\n";