faubackup/src faubackup-find.in,1.4,1.5

Martin Waitz <[email protected]> Fri, 16 Apr 2004 22:58:55 +0000
Newsgroups gmane.comp.sysutils.backup.faubackup.cvs
Message-ID <[email protected]>
Update of /cvsroot/faubackup/faubackup/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27814/src

Modified Files:
	faubackup-find.in 
Log Message:
use Getopt::Long

Index: faubackup-find.in
===================================================================
RCS file: /cvsroot/faubackup/faubackup/src/faubackup-find.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** faubackup-find.in	18 Mar 2004 00:35:27 -0000	1.4
--- faubackup-find.in	16 Apr 2004 22:58:53 -0000	1.5
***************
*** 19,22 ****
--- 19,51 ----
  
  use strict;
+ use Getopt::Long;
+ 
+ 
+ sub printusage($)
+ {
+ 	my $exitcode = shift;
+ 	print "faubackup-find [--noregexp] [ignore list]...\n";
+ 	exit $exitcode if $exitcode>=0;
+ }
+ 
+ sub printhelp()
+ {
+ 	printusage(-1);
+ 	print <<END;
+ 
+ faubackup-find searches for files in the current directory, and prints their
+ name to standard-output. That output is intended to be piped through
+ faubackup-gather, in order to build a backup.
+ END
+ 
+ 	exit 0;
+ }
+ 
+ sub printversion()
+ {
+ 	print "@PACKAGE_STRING@\n";
+ 	exit 0;
+ }
+ 
  
  my $verbose;
***************
*** 38,42 ****
  		if( !$useregexp ) {
  			# replace with known invalid one, check_ignore will warn
! 			$regexp += "/ :-(";
  		}
  	} else {
--- 67,71 ----
  		if( !$useregexp ) {
  			# replace with known invalid one, check_ignore will warn
! 			$regexp .= "/ :-(";
  		}
  	} else {
***************
*** 155,165 ****
  
  
  # command line arguments are used as wildcards of files to ignore
  my @ignorelist;
  foreach (@ARGV) {
- 	if( /^--noregexp$/ ) { #check for the only option
- 		$useregexp = 0;
- 		next;
- 	}
  	# interpret argument as an ignore-match
  	my $regexp = match2regexp $_;
--- 184,203 ----
  
  
+ # command line option parsing
+ my( $usage, $help, $version );
+ GetOptions(
+ 	"help|?" => \$help,
+ 	"usage" => \$usage,
+ 	"version" => \$version,
+ 	"verbose" => \$verbose,
+ 	"regexp!" => \$useregexp
+ ) or printusage(1);
+ printusage(0) if $usage;
+ printhelp() if $help;
+ printversion() if $version;
+ 
  # command line arguments are used as wildcards of files to ignore
  my @ignorelist;
  foreach (@ARGV) {
  	# interpret argument as an ignore-match
  	my $regexp = match2regexp $_;



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click