| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||
| 2 | ###################################################################### | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # batsh.pl - command-line launcher for BATsh | ||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||
| 6 | # Copyright (c) 2026 INABA Hitoshi <ina.cpan@gmail.com> | ||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||
| 8 | # Installed via EXE_FILES so that "batsh.pl script.batsh" works after | ||||||||||||||||||||||||||||
| 9 | # "make install" (ExtUtils::MakeMaker creates a .bat wrapper on Win32). | ||||||||||||||||||||||||||||
| 10 | # The process exit code is the script's exit code. | ||||||||||||||||||||||||||||
| 11 | # | ||||||||||||||||||||||||||||
| 12 | # COMPATIBILITY: Perl 5.005_03 and later | ||||||||||||||||||||||||||||
| 13 | # | ||||||||||||||||||||||||||||
| 14 | ###################################################################### | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 26 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 26 | ▶ | BEGIN { if ($] < 5.006 && !defined(&warnings::import)) { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=16.5
Branch: 1 branch
Condition33%1/3
$] < "5.006" and not defined &warnings::import
MC/DC0%0/2
$] < "5.006" and not defined &warnings::import
$] < "5.006"
not defined &warnings::import
Truth table33%1/3
A and not(B)
A= $] < "5.006"B= not defined &warnings::import
| |||||||||||||||||||||||||||||
| 18 | 0 | $INC{'warnings.pm'} = 'stub'; eval 'package warnings; sub import {}' } } | |||||||||||||||||||||||||||
| 19 | 26 | ▶ | use warnings; local $^W = 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 26 | ▶ | BEGIN { pop @INC if $INC[-1] eq '.' } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # Prefer the sibling lib/ when run from an unpacked distribution | ||||||||||||||||||||||||||||
| 23 | # (perl bin/batsh.pl ...); an installed BATsh is found via @INC as usual. | ||||||||||||||||||||||||||||
| 24 | # | ||||||||||||||||||||||||||||
| 25 | # The sibling directory is added only when the parent really is an | ||||||||||||||||||||||||||||
| 26 | # unpacked BATsh distribution, which is what MANIFEST next to it means. | ||||||||||||||||||||||||||||
| 27 | # An unconditional "use lib" would, once this script is installed into | ||||||||||||||||||||||||||||
| 28 | # (say) /usr/local/bin, put /usr/local/lib at the head of @INC on every | ||||||||||||||||||||||||||||
| 29 | # run; a stale or unrelated BATsh.pm left in that directory would then | ||||||||||||||||||||||||||||
| 30 | # shadow the copy that was just installed. Testing only for the module | ||||||||||||||||||||||||||||
| 31 | # would not help, since that is exactly the case that goes wrong. | ||||||||||||||||||||||||||||
| 32 | 26 | ▶ | use FindBin (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 26 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.8
| |||||||||||||||||||||||||||||
| 34 | 26 | my $root = "$FindBin::Bin/.."; | |||||||||||||||||||||||||||
| 35 | 26 | my $devlib = "$root/lib"; | |||||||||||||||||||||||||||
| 36 | 26 | ▶ | if (-e "$root/MANIFEST" && -e "$devlib/BATsh.pm") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-e "$root/MANIFEST" and -e "$devlib/BATsh.pm"
MC/DC0%0/2
-e "$root/MANIFEST" and -e "$devlib/BATsh.pm"
-e "$root/MANIFEST"
-e "$devlib/BATsh.pm"
Truth table33%1/3
A and B
A= -e "$root/MANIFEST"B= -e "$devlib/BATsh.pm"
| |||||||||||||||||||||||||||||
| 37 | 26 | require lib; | |||||||||||||||||||||||||||
| 38 | 26 | lib->import($devlib); | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 26 | ▶ | use BATsh; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 26 | exit(BATsh->main(@ARGV)); | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | __END__ | ||||||||||||||||||||||||||||