Bug 25752: Stay in cwd after koha-shell

After bug 25538, after a koha-shell we are not longer in the current directory:

root@cec7bffd8100:koha(master)$ pwd
/kohadevbox/koha
root@cec7bffd8100:koha(master)$ sudo koha-shell kohadev
kohadev-koha@cec7bffd8100:~$ pwd
/var/lib/koha/kohadev

Test plan:
Repeat the commands above and confirm that with this version of the
script you get /kohadevbox/koha inside the koha-shell

Search for possible regressions

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2020-06-15 16:11:49 +02:00
parent 2ab6018b6e
commit 7555ecaafa
1 changed files with 2 additions and 1 deletions

View File

@ -20,6 +20,7 @@ use Modern::Perl;
Getopt::Long::Configure("bundling");
my $pwd = `pwd`;
my %opts;
my $res = GetOptions( \%opts, "command|c=s", "help|h", "login|l", "shell|s=s",
"preserve-environment|p|m", "verbose|v" );
@ -51,7 +52,7 @@ push @su_args,
"env "
. "KOHA_CONF=/etc/koha/sites/$instance/koha-conf.xml "
. "PERL5LIB=$perl5lib $shell"
. ( $opts{command} ? " -c '$opts{command}'" : '' );
. ( $opts{command} ? " -c '$opts{command}'" : " -c 'cd \"$pwd\"; $shell'" );
print "Command: '".join("' '",@su_args)."'\n" if $opts{verbose};
system("@su_args");