Skip to content

Commit

Permalink
Item906: make it possible to call bin scripts from any directory
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@2514 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GilmarSantosJr authored and GilmarSantosJr committed Feb 16, 2009
1 parent 22f6d50 commit e3ed824
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 28 deletions.
7 changes: 5 additions & 2 deletions core/bin/attach
Expand Up @@ -36,8 +36,11 @@ BEGIN {
$SIG{__DIE__} = \&Carp::confess;
}
$ENV{FOSWIKI_ACTION} = 'attach';
@INC = ('.', grep { $_ ne '.' } @INC);
require 'setlib.cfg';
require FindBin;
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
}

use Foswiki;
Expand Down
7 changes: 5 additions & 2 deletions core/bin/changes
Expand Up @@ -36,8 +36,11 @@ BEGIN {
$SIG{__DIE__} = \&Carp::confess;
}
$ENV{FOSWIKI_ACTION} = 'changes';
@INC = ('.', grep { $_ ne '.' } @INC);
require 'setlib.cfg';
require FindBin;
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
}

use Foswiki;
Expand Down
7 changes: 5 additions & 2 deletions core/bin/edit
Expand Up @@ -36,8 +36,11 @@ BEGIN {
$SIG{__DIE__} = \&Carp::confess;
}
$ENV{FOSWIKI_ACTION} = 'edit';
@INC = ('.', grep { $_ ne '.' } @INC);
require 'setlib.cfg';
require FindBin;
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
}

use Foswiki;
Expand Down
7 changes: 5 additions & 2 deletions core/bin/login
Expand Up @@ -36,8 +36,11 @@ BEGIN {
$SIG{__DIE__} = \&Carp::confess;
}
$ENV{FOSWIKI_ACTION} = 'login';
@INC = ('.', grep { $_ ne '.' } @INC);
require 'setlib.cfg';
require FindBin;
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
}

use Foswiki;
Expand Down
7 changes: 5 additions & 2 deletions core/bin/logon
Expand Up @@ -36,8 +36,11 @@ BEGIN {
$SIG{__DIE__} = \&Carp::confess;
}
$ENV{FOSWIKI_ACTION} = 'logon';
@INC = ('.', grep { $_ ne '.' } @INC);
require 'setlib.cfg';
require FindBin;
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
}

use Foswiki;
Expand Down
7 changes: 5 additions & 2 deletions core/bin/rdiff
Expand Up @@ -36,8 +36,11 @@ BEGIN {
$SIG{__DIE__} = \&Carp::confess;
}
$ENV{FOSWIKI_ACTION} = 'rdiff';
@INC = ('.', grep { $_ ne '.' } @INC);
require 'setlib.cfg';
require FindBin;
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
}

use Foswiki;
Expand Down
7 changes: 5 additions & 2 deletions core/bin/rdiffauth
Expand Up @@ -36,8 +36,11 @@ BEGIN {
$SIG{__DIE__} = \&Carp::confess;
}
$ENV{FOSWIKI_ACTION} = 'rdiffauth';
@INC = ('.', grep { $_ ne '.' } @INC);
require 'setlib.cfg';
require FindBin;
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
}

use Foswiki;
Expand Down
7 changes: 5 additions & 2 deletions core/bin/register
Expand Up @@ -36,8 +36,11 @@ BEGIN {
$SIG{__DIE__} = \&Carp::confess;
}
$ENV{FOSWIKI_ACTION} = 'register';
@INC = ('.', grep { $_ ne '.' } @INC);
require 'setlib.cfg';
require FindBin;
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
}

use Foswiki;
Expand Down
7 changes: 5 additions & 2 deletions core/bin/rename
Expand Up @@ -36,8 +36,11 @@ BEGIN {
$SIG{__DIE__} = \&Carp::confess;
}
$ENV{FOSWIKI_ACTION} = 'rename';
@INC = ('.', grep { $_ ne '.' } @INC);
require 'setlib.cfg';
require FindBin;
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
}

use Foswiki;
Expand Down
7 changes: 5 additions & 2 deletions core/bin/resetpasswd
Expand Up @@ -36,8 +36,11 @@ BEGIN {
$SIG{__DIE__} = \&Carp::confess;
}
$ENV{FOSWIKI_ACTION} = 'resetpasswd';
@INC = ('.', grep { $_ ne '.' } @INC);
require 'setlib.cfg';
require FindBin;
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
}

use Foswiki;
Expand Down
7 changes: 5 additions & 2 deletions core/bin/rest
Expand Up @@ -36,8 +36,11 @@ BEGIN {
$SIG{__DIE__} = \&Carp::confess;
}
$ENV{FOSWIKI_ACTION} = 'rest';
@INC = ('.', grep { $_ ne '.' } @INC);
require 'setlib.cfg';
require FindBin;
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
}

use Foswiki;
Expand Down
12 changes: 8 additions & 4 deletions core/bin/setlib.cfg
Expand Up @@ -32,14 +32,19 @@

use vars qw( $foswikiLibPath @localPerlLibPath );

eval 'require "LocalLib.cfg"';
require FindBin;
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($LocalLib) = Cwd::abs_path( "$bin/LocalLib.cfg" ) =~ /(.*)/;

eval 'require "'.$LocalLib.'";';

# if foswikiLibPath isn't defined, then see if $twikiLibPath is
# for compatibility
$foswikiLibPath = $twikiLibPath unless defined( $foswikiLibPath );

unless (( defined ($foswikiLibPath) ) and (-e $foswikiLibPath)) {
use Cwd qw( abs_path );
( $foswikiLibPath ) = ($foswikiLibPath = Cwd::abs_path( "../lib" )) =~ /(.*)/;
( $foswikiLibPath ) = ($foswikiLibPath = Cwd::abs_path( "$bin/../lib" )) =~ /(.*)/;
}
if ($foswikiLibPath eq "") {
$foswikiLibPath = "../lib";
Expand All @@ -65,4 +70,3 @@ if ($defaultingCPANBASE) {
}

1; # Return success for module loading

7 changes: 5 additions & 2 deletions core/bin/view
Expand Up @@ -36,8 +36,11 @@ BEGIN {
$SIG{__DIE__} = \&Carp::confess;
}
$ENV{FOSWIKI_ACTION} = 'view';
@INC = ('.', grep { $_ ne '.' } @INC);
require 'setlib.cfg';
require FindBin;
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
}

use Foswiki;
Expand Down

0 comments on commit e3ed824

Please sign in to comment.