From 6518b01e57637028d376ee1a25326cd943e94a34 Mon Sep 17 00:00:00 2001
From: Liz Rea <liz@catalyst.net.nz>
Date: Fri, 16 Oct 2015 15:13:44 +1300
Subject: [PATCH] Bug 13216 - fix koha shell to accept alternative perl5lib
 paths

To test:
gitify an install

run sudo koha-shell instance
run env | grep PERL5LIB it should be set to /usr/share/koha/lib

run sudo koha-shell -d /path/to/your/git/install
run env | grep PERL5LIB it should be set to /path/to/your/git/install
---
 debian/scripts/koha-shell | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/debian/scripts/koha-shell b/debian/scripts/koha-shell
index 8d05b51..013e047 100755
--- a/debian/scripts/koha-shell
+++ b/debian/scripts/koha-shell
@@ -22,7 +22,7 @@ Getopt::Long::Configure("bundling");
 
 my %opts;
 my $res = GetOptions( \%opts, "command|c=s", "help|h", "login|l", "shell|s=s",
-    "preserve-environment|p|m", "verbose|v" );
+    "preserve-environment|p|m", "verbose|v", "kohadir|d=s" );
 
 if ( !$res || $opts{help} ) {
     show_help( !$res );
@@ -39,7 +39,13 @@ if ( !-e "/etc/koha/sites/$instance" ) {
     exit(1);
 }
 my $shell = $opts{shell} || $ENV{SHELL} || '/bin/sh';
-
+my $kohadir;
+if ( $opts{kohadir} ) { 
+    $kohadir = $opts{kohadir};
+}
+else {
+    $kohadir = '/usr/share/koha/lib';
+}
 # Now we're set up, build the 'su' command
 my @su_args;
 push @su_args, '/bin/su';
@@ -48,7 +54,7 @@ push @su_args, '--login' if $opts{login};
 push @su_args, '--command',
     "env "
   . "KOHA_CONF=/etc/koha/sites/$instance/koha-conf.xml "
-  . "PERL5LIB=/usr/share/koha/lib $shell"
+  . "PERL5LIB=$kohadir $shell"
   . ( $opts{command} ? " -c '$opts{command}'" : '' );
 push @su_args, "$instance-koha";
 
@@ -76,13 +82,14 @@ koha-shell -- gives you a shell with your Koha environment set up
 Usage: koha-shell [options] [instance name]
 
 Options:
-    -c, --command COMMAND   pass COMMAND to the invoked shell
-    -h, --help              show this help and quit
-    -l, --login             make the shell a login shell
+    -c, --command COMMAND           pass COMMAND to the invoked shell
+    -h, --help                      show this help and quit
+    -l, --login                     make the shell a login shell
     -m, -p,
-    --preserve-environment  do not reset environment variables
-    -s, --shell SHELL       use SHELL instead of the one from your environment
-    -v, --verbose           output the full command that will be executed
+    --preserve-environment          do not reset environment variables
+    -s, --shell SHELL               use SHELL instead of the one from your environment
+    -v, --verbose                   output the full command that will be executed
+    -d, --kohadir /path/to/koha     use a different PERL5LIB directory, for example in a git install.
 
 The default shell is the one currently in use. Refer to su(1) for more detail
 on these options.
-- 
1.9.1