Skip to content

Commit f80395c

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 fead794 commit f80395c

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
@@ -381,12 +381,21 @@ sub GenerateTimezoneFiles
381381
my $mf = read_file("src/timezone/Makefile");
382382
$mf =~ s{\\\r?\n}{}g;
383383
$mf =~ /^TZDATA\s*:?=\s*(.*)$/m
384-
|| die "Could not find TZDATA row in timezone makefile\n";
384+
|| die "Could not find TZDATA line in timezone makefile\n";
385385
my @tzfiles = split /\s+/, $1;
386-
unshift @tzfiles, '';
386+
387387
print "Generating timezone files...";
388-
system("$conf\\zic\\zic -d \"$target/share/timezone\" "
389-
. join(" src/timezone/data/", @tzfiles));
388+
389+
my @args = ("$conf/zic/zic",
390+
'-d',
391+
"$target/share/timezone");
392+
foreach (@tzfiles)
393+
{
394+
my $tzfile = $_;
395+
push(@args, "src/timezone/data/$tzfile")
396+
}
397+
398+
system(@args);
390399
print "\n";
391400
}
392401

@@ -633,9 +642,10 @@ sub CopyIncludeFiles
633642
next unless (-d "src/include/$d");
634643

635644
EnsureDirectories("$target/include/server/$d");
636-
system(
637-
qq{xcopy /s /i /q /r /y src\\include\\$d\\*.h "$ctarget\\include\\server\\$d\\"}
638-
) && croak("Failed to copy include directory $d\n");
645+
my @args = ('xcopy', '/s', '/i', '/q', '/r', '/y',
646+
"src\\include\\$d\\*.h",
647+
"$ctarget\\include\\server\\$d\\");
648+
system(@args) && croak("Failed to copy include directory $d\n");
639649
}
640650
closedir($D);
641651

@@ -688,9 +698,11 @@ sub GenerateNLSFiles
688698

689699
EnsureDirectories($target, "share/locale/$lang",
690700
"share/locale/$lang/LC_MESSAGES");
691-
system(
692-
"\"$nlspath\\bin\\msgfmt\" -o \"$target\\share\\locale\\$lang\\LC_MESSAGES\\$prgm-$majorver.mo\" $_"
693-
) && croak("Could not run msgfmt on $dir\\$_");
701+
my @args = ("$nlspath\\bin\\msgfmt",
702+
'-o',
703+
"$target\\share\\locale\\$lang\\LC_MESSAGES\\$prgm-$majorver.mo",
704+
$_);
705+
system(@args) && croak("Could not run msgfmt on $dir\\$_");
694706
print ".";
695707
}
696708
}

src/tools/msvc/vcregress.pl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -400,35 +400,41 @@ sub upgradecheck
400400
print "\nRunning initdb on old cluster\n\n";
401401
standard_initdb() or exit 1;
402402
print "\nStarting old cluster\n\n";
403-
system("pg_ctl start -l $logdir/postmaster1.log -w") == 0 or exit 1;
403+
my @args = ('pg_ctl', 'start', '-l', "$logdir/postmaster1.log", '-w');
404+
system(@args) == 0 or exit 1;
404405
print "\nSetting up data for upgrading\n\n";
405406
installcheck();
406407

407408
# now we can chdir into the source dir
408409
chdir "$topdir/src/bin/pg_upgrade";
409410
print "\nDumping old cluster\n\n";
410-
system("pg_dumpall -f $tmp_root/dump1.sql") == 0 or exit 1;
411+
@args = ('pg_dumpall', '-f', "$tmp_root/dump1.sql");
412+
system(@args) == 0 or exit 1;
411413
print "\nStopping old cluster\n\n";
412414
system("pg_ctl -m fast stop") == 0 or exit 1;
413415
$ENV{PGDATA} = "$data";
414416
print "\nSetting up new cluster\n\n";
415417
standard_initdb() or exit 1;
416418
print "\nRunning pg_upgrade\n\n";
417-
system("pg_upgrade -d $data.old -D $data -b $bindir -B $bindir") == 0
418-
or exit 1;
419+
@args = ('pg_upgrade', '-d', "$data.old", '-D', $data, '-b', $bindir,
420+
'-B', $bindir);
421+
system(@args) == 0 or exit 1;
419422
print "\nStarting new cluster\n\n";
420-
system("pg_ctl -l $logdir/postmaster2.log -w start") == 0 or exit 1;
423+
@args = ('pg_ctl', '-l', "$logdir/postmaster2.log", '-w', 'start');
424+
system(@args) == 0 or exit 1;
421425
print "\nSetting up stats on new cluster\n\n";
422426
system(".\\analyze_new_cluster.bat") == 0 or exit 1;
423427
print "\nDumping new cluster\n\n";
424-
system("pg_dumpall -f $tmp_root/dump2.sql") == 0 or exit 1;
428+
@args = ('pg_dumpall', '-f', "$tmp_root/dump2.sql");
429+
system(@args) == 0 or exit 1;
425430
print "\nStopping new cluster\n\n";
426431
system("pg_ctl -m fast stop") == 0 or exit 1;
427432
print "\nDeleting old cluster\n\n";
428433
system(".\\delete_old_cluster.bat") == 0 or exit 1;
429434
print "\nComparing old and new cluster dumps\n\n";
430435

431-
system("diff -q $tmp_root/dump1.sql $tmp_root/dump2.sql");
436+
@args = ('diff', '-q', "$tmp_root/dump1.sql", "$tmp_root/dump2.sql");
437+
system(@args);
432438
$status = $?;
433439
if (!$status)
434440
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy