[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[CONTRIB] `sfind', a wrapper around `find' that ignores .svn directories

From: Eric Hanchrow <offby1_at_blarg.net>
Date: 2005-03-03 17:28:55 CET

I use this (surprisingly complicated :-( ) script constantly, and have
told Emacs to use it instead of `find'. I suspect it'd be useful for
other *nix svn users too.

I have a sneaking suspicion that it doesn't do the right thing in
every case, but I haven't nailed it down. In any case, it's mighty

    #!/usr/bin/perl -w

    use strict;
    use Data::Dumper;

    # A wrapper around GNU find. It ignores Subversion cache directories,
    # but otherwise acts the same.

    # Subversion includes a similar tool in
    # .../contrib/client-side/wcgrep; it runs a recursive grep, ignoring
    # Subversion cache directories.

    my @files;
    my @expression_bits;

    # Consume find's arguments, one by one. As soon as we see an argument
    # that looks like an expression, then it and every remaining argument
    # are expressions. Until then, all the arguments are files.

    push @files , shift @ARGV while (@ARGV && $ARGV[0] !~ m{^[-(!]});

    push @expression_bits, shift @ARGV while (@ARGV);

    # We need to add `-print' if they didn't specify actions. Actions
    # begin with hyphens, so they're easy to recognize ... except they
    # might be buried inside parentheses.

      my @tmp = @expression_bits;

      # Get rid of any trailing right-parens.
      pop @tmp while (@tmp && $tmp[-1] eq ")");

      push @expression_bits, qw(-print)
        unless (@tmp
                && ($tmp[-1] =~ m(^-) # most action arguments begin with a hyphen.

                    || $tmp[-1] eq ";" # the last argument to `-exec' is
                                       # always a semicolon.

    unshift @expression_bits, qw(( -type d -name .svn -prune ) -o);

    # Let's get GNU find if possible
    my $prog = "find";

    if ($^O =~ m(freebsd)i) {
      my $gf = "/usr/local/bin/gfind";
      $prog = $gf if (-x $gf);

    exec ($prog, @files, @expression_bits);

Because he pays close attention, a Navy pilot can land a
40,000 lb. aircraft at 140 miles per hour on a pitching carrier
deck, at night, more safely than the average teenager can cut a
        -- Paul Graham
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Mar 3 17:59:29 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.