From e56a718b2213a30a47b832291dcd620568408682 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 31 Jul 2013 12:59:47 -0400 Subject: [PATCH] [scripts] AggSetCoord: -I option (backup suffix) --- scripts/owlps-aggsetcoord.pl | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/owlps-aggsetcoord.pl b/scripts/owlps-aggsetcoord.pl index d0cede5..4c5fdcd 100755 --- a/scripts/owlps-aggsetcoord.pl +++ b/scripts/owlps-aggsetcoord.pl @@ -10,7 +10,7 @@ owlps-aggsetcoord - set the coordinates in an aggregation CSV file B [ B<-h> | B<-V> ] [ B<-v> ] -[ B<-i> ] +[ B<-i> | B<-I> > ] [ B<-c> > [ B<-l> > ] ] [ B<-m> > ] [ > ] @@ -72,6 +72,12 @@ Turn on verbose mode (displays a trace on the standard error). Modify the input file in-place. The original file is saved with suffix ".orig". +=item B<-I> > + +Same as B<-i>, but the original file is suffixed with I instead of +".orig". If both B<-i> and B<-I> are used, the latter has precedence over the +former. If I is an empty string, this option is ignored. + =item B<-c> > Apply I to every positioning request with default X, Y and Z. A @@ -145,6 +151,9 @@ my $output_handle = *STDOUT; # Names of the temporary and final output files my ($tmp_output_file, $output_file); +# Suffix with which the original file is saved +my $backup_suffix; + # Verbose mode my $verbose; @@ -339,7 +348,7 @@ sub apply_interpolation($$$$$$) { ## Option parsing ## $Getopt::Std::STANDARD_HELP_VERSION = 1; -use constant OPTIONS => 'c:hil:m:vV'; +use constant OPTIONS => 'c:hiI:l:m:vV'; my %options; if (!getopts(OPTIONS, \%options)) { HELP_MESSAGE(*STDERR); @@ -359,12 +368,14 @@ if ($options{'V'}) { $verbose = $options{'v'}; $new_coordinates = $options{'c'}; +$backup_suffix = $options{'I'}; $selected_mac = $options{'m'}; -if ($options{'i'}) { +if ($options{'i'} || $backup_suffix) { if (@ARGV != 1) { - die "One and only one file name must be provided when using -i"; + die "One and only one file name must be provided when using -i or -I"; } + $backup_suffix ||= ".orig"; $output_file = $ARGV[0]; ($output_handle, $tmp_output_file) = tempfile( @@ -631,7 +642,7 @@ if (defined($output_file)) { or die "Can't close the output file handle: $!"; # Backup the original file - my $newname = "$output_file.orig"; + my $newname = $output_file . $backup_suffix; move($output_file, $newname) or die "Can't move \"$output_file\" to \"$newname\": $!";