From d51cebacff3e88f9a1fa38cdf928d88a1815138f Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sun, 1 Mar 2015 22:36:36 -0800 Subject: [PATCH] toolbox/*.pl: eliminate unnecessary use of the shell Switch to multi-arg system and 3-arg open to avoid unnecessary spawning of the POSIX shell. --- toolbox/remirror-project.pl | 2 +- toolbox/trash-project.pl | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/toolbox/remirror-project.pl b/toolbox/remirror-project.pl index 9823376..5234adf 100755 --- a/toolbox/remirror-project.pl +++ b/toolbox/remirror-project.pl @@ -34,7 +34,7 @@ if ($p->{clone_in_progress} && !$p->{clone_failed}) { unlink($p->_clonefail_path); unlink($p->_clonelog_path); my $cp = $p->_clonep_path; -open X, '>'.$cp or die "failed to create $cp: $!"; +open X, '>', $cp or die "failed to create $cp: $!"; close X; my $sock = IO::Socket::UNIX->new($Girocco::Config::chroot.'/etc/taskd.socket') or die "cannot connect to taskd.socket: $!"; diff --git a/toolbox/trash-project.pl b/toolbox/trash-project.pl index 1ddd972..8c55a75 100755 --- a/toolbox/trash-project.pl +++ b/toolbox/trash-project.pl @@ -47,8 +47,10 @@ if ($keep_forks) { my $reporoot = $Girocco::Config::reporoot; my $basedir = $Girocco::Config::basedir; print "We have to run GC on the repo so that the forks don't lose data. Hang on...\n"; - system("GIT_DIR=$reporoot/$project.git git config --unset gitweb.lastgc"); - system("show_progress=1 $basedir/jobd/gc.sh $project"); + system($Girocco::Config::git_bin, "--git-dir=$reporoot/$project.git", 'config', + '--unset', 'gitweb.lastgc'); + $ENV{'show_progress'} = 1; + system("$basedir/jobd/gc.sh", $project); } else { die "Complicated situation: project still has forks. Please deal with it manually." if (-d "$Girocco::Config::reporoot/$project/"); @@ -61,13 +63,16 @@ if (!$delete) { if ($project =~ m!/!) { my $parent = $project; $parent =~ s{^(.+)/.*$}{$1}; - system("mkdir -p '$bin/$parent'") == 0 || die "Problem creating directory hierarchy in recycle bin: $!"; + system('mkdir', '-p', "$bin/$parent") == 0 or + die "Problem creating directory hierarchy in recycle bin: $!"; } rename $p->{'path'}, "$bin/$project.git" || die "Problem moving project data: $!"; my ($S,$M,$H,$d,$m,$y) = gmtime(time()); my $recycletime = strftime("%Y-%m-%dT%H:%M:%SZ", $S, $M, $H, $d, $m, $y, -1, -1, -1); - system("GIT_DIR=$bin/$project.git git config girocco.recycletime $recycletime"); + system($Girocco::Config::git_bin, "--git-dir=$bin/$project.git", 'config', + 'girocco.recycletime', $recycletime); } $p->delete(); -print "Project '$project' removed from $Girocco::Config::name". ($delete ? '' : ", backup in $bin/$project.git") .".\n"; +print "Project '$project' removed from $Girocco::Config::name". + ($delete ? '' : ", backup in $bin/$project.git") .".\n"; -- 2.11.4.GIT