Oliver Fromme <[EMAIL PROTECTED]> wrote:

> Uhm...  Maybe I misunderstand what your 100-line perl script
> does, but I use the following 3-line shell script instead:
> 
>    #!/bin/sh -
>    cvs status | grep '^File:' | grep -v 'Status: Up-to-date$'
>    true

     This works (and is faster), but it doesn't give you concise,
nicely-formatted pathnames.  Personally, I prefer status like:

i386/linux/linux_file.c                            Locally Modified
kern/imgact_elf.c                                  Locally Modified

instead of:

cvs server: Examining aaa ...
cvs server: Examining bbb ...
cvs server: Examining ccc ...
cvs server: Examining ddd ...
cvs server: Examining eee ...
File: linux_file.c          Status: Locally Modified
cvs server: Examining fff ...
cvs server: Examining ggg ...
File imgact_elf.c           Status: Locally Modified

I think the script's output is easier to read.

[ Hmmm, but you do incidentally bring up a point: it's better to parse
  the output of "cvs status -R", instead of the ugly way used by the
  script.  I've attached a newer, faster version.  Instead of taking
  around 3 minutes to list the status below /usr/src/sys, this new
  version takes around 1 minute.  I've also applied Anton's fix.  ]

--
        Darryl Okahata
        [EMAIL PROTECTED]

DISCLAIMER: this message is the author's personal opinion and does not
constitute the support, opinion, or policy of Hewlett-Packard, or of the
little green men that have been following him all day.

#! /usr/bin/perl
###############################################################################
#
# File:         cvsinfo
# RCS:          $Header: $
# Description:  List CVS files in the current directory and below that are
#               not up-to-date.  These files are typically those which have
#               been modified or need updating.
#
#               This is a new, rewritten, version, thanks to feedback from
#               Anton Berezin <[EMAIL PROTECTED]> and
#               Oliver Fromme <[EMAIL PROTECTED]>.
#
#               Usage:
#
#                       cvsinfo [-a] [-l]
#
#               Options:
#
#               -a      Show status of all files, and not just those which
#                       are not up-to-date.
#
#               -l      Show status of files in the current directory only.
#                       Do not recurse into subdirectories.
#
# Author:       Darryl Okahata
# Created:      Thu Sep 23 14:32:34 1999
# Modified:     Thu Sep 23 14:45:03 1999 (Darryl Okahata) [EMAIL PROTECTED]
# Language:     CPerl
# Package:      N/A
# Status:       Experimental
#
# (C) Copyright 1999, Hewlett-Packard, all rights reserved.
#
###############################################################################

###############################################################################

require 'getopts.pl';
&Getopts('al');
$all_status = 1 if ($opt_a);

# Explicitly specify options, just in case the user has overridden them in
# ~/.cvsrc.
if ($opt_l) {
    $recursive = "-l";
} else {
    $recursive = "-R";
}

$dir = ".";
open(IN, "cvs status $recursive 2>&1 |") || die "$!";
while(<IN>) {
    if (/^cvs\s+server:\s+Examining\s+([^\s].*)$/) {
        $dir = $1;
    } elsif (/^File:\s+(?:no\s+file\s+)?([^\s]+)\s+Status:\s+(.+)$/i){
        $file = $1;
        $status = $2;
        if ($all_status || $status ne 'Up-to-date') {
            if ($status eq 'Needs Patch') {
                $status = 'Needs Updating';
            }
            printf("%-50s %s\n", ($dir eq '.') ? $file : "$dir/$file",
                   $status);
            if ($status =~ /Locally Modified/) {
                push(@update_files, $file);
            }
        }
    } elsif (/\[status\s+aborted\]/) {
        die "$_\n";
    }
}

Reply via email to