13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 1 ■ SAVING YOURSELF EFFORTwith all to add all the remaining ones or end to skip all the rest at any point), and then add and committhem with your message:01 #!/usr/bin/perl -w02 #03 # Script to add multiple files to Subversion by running SVN status and asking04 # for confirmation.05 # Usage: svnmultiadd "message"06 # Juliet Kemp 04.03.20090708 use strict;0910 die "Usage: svnmultiadd 'message'\n" if $#ARGV != 0;1112 my $msg = " -m '$ARGV[0]'";1314 my $filelist;15 my $all;16 open ( SVN, "svn status 2>&1 |" ) or die ("Couldn't get svn status: $!");17 while () {18 die "Not a SVN working copy directory" if (/not a working copy/);;19 my ($status, $file) = split;20 next unless $status eq "?";21 unless ($all) {22 print "Add $file? (Y/n/all/end) :";23 my $add = ;24 chomp $add;25 last if $add eq "end";26 next if ($add eq "n") || ($add eq "N");27 ($all = 1) if $add eq "all";28 }29 $filelist .= "$file ";30 }3132 print "Adding files $filelist \nGo ahead? (Y/n)\n";33 my $confirm = ;34 chomp $confirm;35 if ( $confirm =~ /[^Yy$]/ ) {36 `svn add $filelist; svn commit $msg`;37 } else {38 print "Add cancelled.\n";39 }As it stands, this will commit everything in the directory, not just your adds; in other words, it willalso commit any edited files. To commit only the added files, change line 36 to this:`svn add $filelist; svn commit $msg $filelist`12Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!