Skip to content

Commit

Permalink
Allow genesis bosh to reference relative files
Browse files Browse the repository at this point in the history
[Bug Fixes]

* The `genesis bosh` command now runs in the users calling directory, so
  relative paths to files work as expected.
  • Loading branch information
dennisjbell committed Mar 18, 2022
1 parent 903baae commit 70c6c85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bin/genesis
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ use FindBin;
$ENV{GENESIS_CALLBACK_BIN} ||= $FindBin::Bin.'/'.$FindBin::Script;
$ENV{GENESIS_LIB} ||= $FindBin::Bin.'/lib';
$ENV{GENESIS_VERSION}=$Genesis::VERSION;
$ENV{GENESIS_ORIGINATING_DIR}=Cwd::getcwd;
our $CALL = join(" ", map {$_ =~ / / ? "\"$_\"" : $_} (humanize_bin, @ARGV));

our %GENESIS_COMMANDS;
Expand Down Expand Up @@ -1815,7 +1816,7 @@ sub {
explain STDERR "Exported environmental variables for BOSH director %s", $bosh->{alias};
exit 0;
} else {
my (undef, $rc) = $bosh->execute({interactive => 1}, @args);
my (undef, $rc) = $bosh->execute({interactive => 1, dir => $ENV{GENESIS_ORIGINATING_DIR}}, @args);
exit $rc;
}
});
Expand Down
3 changes: 3 additions & 0 deletions lib/Genesis.pm
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ sub run {
if (!$opts{interactive} && $opts{stderr}) {
$prog .= " 2>$opts{stderr}";
}
pushd($opts{dir}) if ($opts{dir});

$tracemsg .= csprintf("#M{From directory:} #C{%s}\n", Cwd::getcwd);
$tracemsg .= csprintf("#M{Executing:} `#C{%s}`%s", $prog, ($opts{interactive} ? " #Y{(interactively)}" : ''));
if (@args) {
Expand Down Expand Up @@ -552,6 +554,7 @@ sub run {
dump_var -1, run_stderr => $err if (defined($err));
trace("command exited #G{0}");
}
popd() if ($opts{dir});

return unless defined(wantarray);
return ($rc == 0) if $opts{passfail};
Expand Down

0 comments on commit 70c6c85

Please sign in to comment.