2 # Batch EXecutor 3.0 -- Master Program
3 # (c) 2012 Martin Mares <mj@ucw.cz>
9 my $bex_home = $ENV{"BEX_HOME"} // ".";
10 my $bex_lib = $ENV{"BEX_LIB"} // "lib";
12 Getopt::Long::Configure('require_order');
14 "home=s" => \$bex_home,
17 print "Usage: brum\n";
21 print "BEX 3.0 (c) 2011-2012 Martin Mares <mj\@ucw.cz>\n";
23 ) or die "Try `bex --help' for more information.\n";
24 Getopt::Long::Configure('default');
27 die "BEX home directory $bex_home does not exist.\n";
29 if (!-d "$bex_home/BEX") {
30 die "BEX home directory $bex_home does not contain the BEX subdirectory.\n";
33 @ARGV or die "Missing subcommand.\n";
34 my $sub = shift @ARGV;
35 $sub =~ /^[0-9a-zA-Z]+$/ or die "Invalid subcommand $sub\n";
42 if (defined $aliases{$sub}) { $sub = $aliases{$sub}; }
44 my $sub_path = "$bex_lib/bin/$sub";
45 -x $sub_path or die "Unknown subcommand $sub\n";
47 $ENV{"BEX_HOME"} = $bex_home;
48 $ENV{"BEX_LIB"} = $bex_lib;
49 $ENV{"PERL5LIB"} = join(":", $bex_lib . "/perl", $ENV{"PERL5LIB"} // ());
50 exec $sub_path, @ARGV;
51 die "Cannot execute $sub_path: $!\n";