my $reverse = __cwd($subdir,%opts);
BAIL_OUT("FAILURE: indir, \"$subdir\" wasn't possible to move into")
- unless $reverse;
+ unless $reverse;
$codeblock->();
return () if !$cmd;
my $prefix = "";
- if ( $^O eq "VMS" ) { # VMS
- $prefix = "pipe ";
+ if ( $^O eq "VMS" ) { # VMS
+ $prefix = "pipe ";
}
my @r = ();
$? = 0;
if ($opts{capture}) {
- return @r;
+ return @r;
} else {
- return $r;
+ return $r;
}
}
my $tb = Test::More->builder;
my $failure = scalar(grep { $_ == 0; } $tb->summary);
if ($failure && $end_with_bailout) {
- BAIL_OUT("Stoptest!");
+ BAIL_OUT("Stoptest!");
}
}
=cut
sub bldtop_dir {
- my $d = __bldtop_dir(@_); # This caters for operating systems that have
- # a very distinct syntax for directories.
+ my $d = __bldtop_dir(@_); # This caters for operating systems that have
+ # a very distinct syntax for directories.
croak "$d isn't a directory" if -e $d && ! -d $d;
return $d;
=cut
sub srctop_dir {
- my $d = __srctop_dir(@_); # This caters for operating systems that have
- # a very distinct syntax for directories.
+ my $d = __srctop_dir(@_); # This caters for operating systems that have
+ # a very distinct syntax for directories.
croak "$d isn't a directory" if -e $d && ! -d $d;
return $d;
sub pipe {
my @cmds = @_;
return
- sub {
- my @cs = ();
- my @dcs = ();
- my @els = ();
- my $counter = 0;
- foreach (@cmds) {
- my ($c, $dc, @el) = $_->(++$counter);
-
- return () if !$c;
-
- push @cs, $c;
- push @dcs, $dc;
- push @els, @el;
- }
- return (
- join(" | ", @cs),
- join(" | ", @dcs),
- @els
- );
+ sub {
+ my @cs = ();
+ my @dcs = ();
+ my @els = ();
+ my $counter = 0;
+ foreach (@cmds) {
+ my ($c, $dc, @el) = $_->(++$counter);
+
+ return () if !$c;
+
+ push @cs, $c;
+ push @dcs, $dc;
+ push @els, @el;
+ }
+ return (
+ join(" | ", @cs),
+ join(" | ", @dcs),
+ @els
+ );
};
}
my %saved_hooks = ();
foreach (keys %opts) {
- $saved_hooks{$_} = $hooks{$_} if exists($hooks{$_});
- $hooks{$_} = $opts{$_};
+ $saved_hooks{$_} = $hooks{$_} if exists($hooks{$_});
+ $hooks{$_} = $opts{$_};
}
$codeblock->();
foreach (keys %saved_hooks) {
- $hooks{$_} = $saved_hooks{$_};
+ $hooks{$_} = $saved_hooks{$_};
}
}
# if that one is defined.
sub __exeext {
my $ext = "";
- if ($^O eq "VMS" ) { # VMS
- $ext = ".exe";
+ if ($^O eq "VMS" ) { # VMS
+ $ext = ".exe";
} elsif ($^O eq "MSWin32") { # Windows
- $ext = ".exe";
+ $ext = ".exe";
}
return $ENV{"EXE_EXT"} || $ext;
}
# abs_path().
$dir = canonpath($dir);
if ($opts{create}) {
- mkpath($dir);
+ mkpath($dir);
}
my $abscurdir = abs_path(curdir());
# PARANOIA: if we're not moving anywhere, we do nothing more
if ($abscurdir eq $absdir) {
- return $reverse;
+ return $reverse;
}
# Do not support a move to a different volume for now. Maybe later.
BAIL_OUT("FAILURE: \"$dir\" moves to a different volume, not supported")
- if $reverse eq $abscurdir;
+ if $reverse eq $abscurdir;
# If someone happened to give a directory that leads back to the current,
# it's extremely silly to do anything more, so just simulate that we did
# they don't change!)
my @dirtags = sort keys %directories;
foreach (@dirtags) {
- if (!file_name_is_absolute($directories{$_})) {
- my $oldpath = abs_path($directories{$_});
- my $newpath = abs2rel($oldpath, $absdir);
- if ($debug) {
- print STDERR "DEBUG: [dir $_] old path: $oldpath\n";
- print STDERR "DEBUG: [dir $_] new base: $absdir\n";
- print STDERR "DEBUG: [dir $_] resulting new path: $newpath\n";
- }
- $tmp_directories{$_} = $newpath;
- }
+ if (!file_name_is_absolute($directories{$_})) {
+ my $oldpath = abs_path($directories{$_});
+ my $newpath = abs2rel($oldpath, $absdir);
+ if ($debug) {
+ print STDERR "DEBUG: [dir $_] old path: $oldpath\n";
+ print STDERR "DEBUG: [dir $_] new base: $absdir\n";
+ print STDERR "DEBUG: [dir $_] resulting new path: $newpath\n";
+ }
+ $tmp_directories{$_} = $newpath;
+ }
}
# Treat each environment variable that was used to get us the values in
# %directories the same was as the paths in %directories, so any sub
# process can use their values properly as well
foreach (@direnv) {
- if (!file_name_is_absolute($ENV{$_})) {
- my $oldpath = abs_path($ENV{$_});
- my $newpath = abs2rel($oldpath, $absdir);
- if ($debug) {
- print STDERR "DEBUG: [env $_] old path: $oldpath\n";
- print STDERR "DEBUG: [env $_] new base: $absdir\n";
- print STDERR "DEBUG: [env $_] resulting new path: $newpath\n";
- }
- $tmp_ENV{$_} = $newpath;
- }
+ if (!file_name_is_absolute($ENV{$_})) {
+ my $oldpath = abs_path($ENV{$_});
+ my $newpath = abs2rel($oldpath, $absdir);
+ if ($debug) {
+ print STDERR "DEBUG: [env $_] old path: $oldpath\n";
+ print STDERR "DEBUG: [env $_] new base: $absdir\n";
+ print STDERR "DEBUG: [env $_] resulting new path: $newpath\n";
+ }
+ $tmp_ENV{$_} = $newpath;
+ }
}
# Should we just bail out here as well? I'm unsure.
}
if ($debug) {
- print STDERR "DEBUG: __cwd(), directories and files:\n";
- print STDERR " Moving from $abscurdir\n";
- print STDERR " Moving to $absdir\n";
- print STDERR "\n";
- print STDERR " \$directories{BLDTEST} = \"$directories{BLDTEST}\"\n";
- print STDERR " \$directories{SRCTEST} = \"$directories{SRCTEST}\"\n";
- print STDERR " \$directories{SRCDATA} = \"$directories{SRCDATA}\"\n"
+ print STDERR "DEBUG: __cwd(), directories and files:\n";
+ print STDERR " Moving from $abscurdir\n";
+ print STDERR " Moving to $absdir\n";
+ print STDERR "\n";
+ print STDERR " \$directories{BLDTEST} = \"$directories{BLDTEST}\"\n";
+ print STDERR " \$directories{SRCTEST} = \"$directories{SRCTEST}\"\n";
+ print STDERR " \$directories{SRCDATA} = \"$directories{SRCDATA}\"\n"
if exists $directories{SRCDATA};
- print STDERR " \$directories{RESULTS} = \"$directories{RESULTS}\"\n";
- print STDERR " \$directories{BLDAPPS} = \"$directories{BLDAPPS}\"\n";
- print STDERR " \$directories{SRCAPPS} = \"$directories{SRCAPPS}\"\n";
- print STDERR " \$directories{SRCTOP} = \"$directories{SRCTOP}\"\n";
- print STDERR " \$directories{BLDTOP} = \"$directories{BLDTOP}\"\n";
- print STDERR "\n";
- print STDERR " the way back is \"$reverse\"\n";
+ print STDERR " \$directories{RESULTS} = \"$directories{RESULTS}\"\n";
+ print STDERR " \$directories{BLDAPPS} = \"$directories{BLDAPPS}\"\n";
+ print STDERR " \$directories{SRCAPPS} = \"$directories{SRCAPPS}\"\n";
+ print STDERR " \$directories{SRCTOP} = \"$directories{SRCTOP}\"\n";
+ print STDERR " \$directories{BLDTOP} = \"$directories{BLDTOP}\"\n";
+ print STDERR "\n";
+ print STDERR " the way back is \"$reverse\"\n";
}
return $reverse;
$cmdstr .= "$stdin$stdout$stderr";
if ($debug) {
- print STDERR "DEBUG[__decorate_cmd]: \$cmdstr = \"$cmdstr\"\n";
- print STDERR "DEBUG[__decorate_cmd]: \$display_cmd = \"$display_cmd\"\n";
+ print STDERR "DEBUG[__decorate_cmd]: \$cmdstr = \"$cmdstr\"\n";
+ print STDERR "DEBUG[__decorate_cmd]: \$display_cmd = \"$display_cmd\"\n";
}
return ($cmdstr, $display_cmd);