8000 Fix TAP tests and MSVC scripts for pathnames with spaces. · rtpg/postgres@02a898b · GitHub
[go: up one dir, main page]

Skip to content

Commit 02a898b

Browse files
committed
Fix TAP tests and MSVC scripts for pathnames with spaces.
Change assorted places in our Perl code that did things like system("prog $path/file"); to do it more like system('prog', "$path/file"); which is safe against spaces and other special characters in the path variable. The latter was already the prevailing style, but a few bits of code hadn't gotten this memo. Back-patch to 9.4 as relevant. Michael Paquier, Kyotaro Horiguchi Discussion: <20160704.160213.111134711.horiguchi.kyotaro@lab.ntt.co.jp>
1 parent 2dc7da9 commit 02a898b

File tree

2 files changed

+35
-17
lines changed

2 files changed

+35
-17
lines changed

src/tools/msvc/Install.pm

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,21 @@ sub GenerateTimezoneFiles
343343
my $mf = read_file("src/timezone/Makefile");
344344
$mf =~ s{\\\s*[\r\n]+}{}mg;
345345
$mf =~ /^TZDATA\s*:?=\s*(.*)$/m
346-
|| die "Could not find TZDATA row in timezone makefile\n";
346+
|| die "Could not find TZDATA line in timezone makefile\n";
347347
my @tzfiles = split /\s+/, $1;
348-
unshift @tzfiles, '';
348+
349349
print "Generating timezone files...";
350-
system("$conf\\zic\\zic -d \"$target/share/timezone\" "
351-
. join(" src/timezone/data/", @tzfiles));
350+
351+
my @args = ("$conf/zic/zic",
352+
'-d',
353+
"$target/share/timezone");
354+
foreach (@tzfiles)
355+
{
356+
my $tzfile = $_;
357+
push(@args, "src/timezone/data/$tzfile")
358+
}
359+
360+
system(@args);
352361
print "\n";
353362
}
354363

@@ -581,9 +590,10 @@ sub CopyIncludeFiles
581590
next unless (-d "src/include/$d");
582591

583592
EnsureDirectories("$target/include/server/$d");
584-
system(
585-
qq{xcopy /s /i /q /r /y src\\include\\$d\\*.h "$ctarget\\include\\server\\$d\\"}
586-
) && croak("Failed to copy include directory $d\n");
593+
my @args = ('xcopy', '/s', '/i', '/q', '/r', '/y',
594+
"src\\include\\$d\\*.h",
595+
"$ctarget\\include\\server\\$d\\");
596+
system(@args) && croak("Failed to copy include directory $d\n");
587597
}
588598
closedir($D);
589599

@@ -636,9 +646,11 @@ sub GenerateNLSFiles
636646

637647
EnsureDirectories($target, "share/locale/$lang",
638648
"share/locale/$lang/LC_MESSAGES");
639-
system(
640-
"\"$nlspath\\bin\\msgfmt\" -o \"$target\\share\\locale\\$lang\\LC_MESSAGES\\$prgm-$majorver.mo\" $_"
641-
) && croak("Could not run msgfmt on $dir\\$_");
649+
my @args = ("$nlspath\\bin\\msgfmt",
650+
'-o',
651+
"$target\\share\\locale\\$lang\\LC_MESSAGES\\$prgm-$majorver.mo",
652+
$_);
653+
system(@args) && croak("Could not run msgfmt on $dir\\$_");
642654
print ".";
643655
}
644656
}

src/tools/msvc/vcregress.pl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,35 +340,41 @@ sub upgradecheck
340340
print "\nRunning initdb on old cluster\n\n";
341341
standard_initdb() or exit 1;
342342
print "\nStarting old cluster\n\n";
343-
system("pg_ctl start -l $logdir/postmaster1.log -w") == 0 or exit 1;
343+
my @args = ('pg_ctl', 'start', '-l', "$logdir/postmaster1.log", '-w');
344+
system(@args) == 0 or exit 1;
344345
print "\nSetting up data for upgrading\n\n";
345346
installcheck();
346347

347348
# now we can chdir into the source dir
348349
chdir "$topdir/contrib/pg_upgrade";
349350
print "\nDumping old cluster\n\n";
350-
system("pg_dumpall -f $tmp_root/dump1.sql") == 0 or exit 1;
351+
@args = ('pg_dumpall', '-f', "$tmp_root/dump1.sql");
352+
system(@args) == 0 or exit 1;
351353
print "\nStopping old cluster\n\n";
352354
system("pg_ctl -m fast stop") == 0 or exit 1;
353355
$ENV{PGDATA} = "$data";
354356
print "\nSetting up new cluster\n\n";
355357
standard_initdb() or exit 1;
356358
print "\nRunning pg_upgrade\n\n";
357-
system("pg_upgrade -d $data.old -D $data -b $bindir -B $bindir") == 0
358-
or exit 1;
359+
@args = ('pg_upgrade', '-d', "$data.old", '-D', $data, '-b', $bindir,
360+
'-B', $bindir);
361+
system(@args) == 0 or exit 1;
359362
print "\nStarting new cluster\n\n";
360-
system("pg_ctl -l $logdir/postmaster2.log -w start") == 0 or exit 1;
363+
@args = ('pg_ctl', '-l', "$logdir/postmaster2.log", '-w', 'start');
364+
system(@args) == 0 or exit 1;
361365
print "\nSetting up stats on new cluster\n\n";
362366
system(".\\analyze_new_cluster.bat") == 0 or exit 1;
363367
print "\nDumping new cluster\n\n";
364-
system("pg_dumpall -f $tmp_root/dump2.sql") == 0 or exit 1;
368+
@args = ('pg_dumpall', '-f', "$tmp_root/dump2.sql");
369+
system(@args) == 0 or exit 1;
365370
print "\nStopping new cluster\n\n";
366371
system("pg_ctl -m fast stop") == 0 or exit 1;
367372
print "\nDeleting old cluster\n\n";
368373
system(".\\delete_old_cluster.bat") == 0 or exit 1;
369374
print "\nComparing old and new cluster dumps\n\n";
370375

371-
system("diff -q $tmp_root/dump1.sql $tmp_root/dump2.sql");
376+
@args = ('diff', '-q', "$tmp_root/dump1.sql", "$tmp_root/dump2.sql");
377+
system(@args);
372378
$status = $?;
373379
if (!$status)
374380
{

0 commit comments

Comments
 (0)
0