Update of /cvsroot/fink/scripts/10.4-update
In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv1273
Modified Files:
ChangeLog update.pl
Log Message:
Factor out a common function
Index: update.pl
===================================================================
RCS file: /cvsroot/fink/scripts/10.4-update/update.pl,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- update.pl 14 Jun 2006 20:47:19 -0000 1.10
+++ update.pl 14 Jun 2006 21:15:11 -0000 1.11
@@ -40,17 +40,7 @@
### restart as root if necessary
if ($> != 0) {
- my ($cmd, $arg);
- $cmd = "sudo ./update.pl";
- foreach $arg (@ARGV) {
- if ($arg =~ /^[A-Za-z0-9_.+-]+$/) {
- $cmd .= " $arg";
- } else {
- # safety first (protect shell metachars, quote whole
string)
- $arg =~ s/[\$\`\'\"|;]/_/g;
- $cmd .= " \"$arg\"";
- }
- }
+ my $cmd = &protect_args('sudo ./update.pl',@ARGV);
&Fink::Services::execute($cmd, quiet=>1);
exit 0;
}
@@ -110,18 +100,7 @@
&Fink::Services::execute("dpkg -i base-$distribution/fink-mirrors_*");
&Fink::Services::execute("dpkg -i base-$distribution/fink_*");
-
- my ($cmd, $arg);
- $cmd = "export FINK_UPDATED=true; ./update.pl";
- foreach $arg (@ARGV) {
- if ($arg =~ /^[A-Za-z0-9_.+-]+$/) {
- $cmd .= " $arg";
- } else {
- # safety first (protect shell metachars, quote whole
string)
- $arg =~ s/[\$\`\'\"|;]/_/g;
- $cmd .= " \"$arg\"";
- }
- }
+ my $cmd = &protect_args('FINK_UPDATED=true ./update.pl',@ARGV);
&Fink::Services::execute($cmd, quiet=>1);
exit 0;
}
@@ -154,5 +133,20 @@
exit 0;
+# given a command and an optional list of args, return a command
+# string in which shell metachars in the args are protected
+sub protect_args {
+ my $cmd = shift;
-
+ my $arg;
+ foreach $arg (@_) {
+ if ($arg =~ /^[A-Za-z0-9_.+-]+$/) {
+ $cmd .= " $arg";
+ } else {
+ # safety first (protect shell metachars, quote whole
string)
+ $arg =~ s/[\$\`\'\"|;]/_/g;
+ $cmd .= " \"$arg\"";
+ }
+ }
+ return $cmd;
+}
Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/scripts/10.4-update/ChangeLog,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ChangeLog 14 Jun 2006 20:15:32 -0000 1.8
+++ ChangeLog 14 Jun 2006 21:15:11 -0000 1.9
@@ -1,7 +1,8 @@
2006-06-14 Daniel Macks <[EMAIL PROTECTED]>
* update.pl: print_breaking accepts multiple paragraphs. Don't
- bother sudo'ing if we are already root.
+ bother sudo'ing if we are already root. Factor out function to
+ protect shell metachars.
2006-06-14 Dave Morrison <[EMAIL PROTECTED]>
_______________________________________________
Fink-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fink-commits