| 1 | # | ||||||||||
| 2 | # Copyright (c) 2007-2020 Christian Jaeger, copying@christianjaeger.ch | ||||||||||
| 3 | # | ||||||||||
| 4 | # This is free software, offered under either the same terms as perl 5 | ||||||||||
| 5 | # or the terms of the Artistic License version 2 or the terms of the | ||||||||||
| 6 | # MIT License (Expat version). See the file COPYING.md that came | ||||||||||
| 7 | # bundled with this file. | ||||||||||
| 8 | # | ||||||||||
| 9 | |||||||||||
| 10 | =head1 NAME | ||||||||||
| 11 | |||||||||||
| 12 | Chj::Unix::Exitcode | ||||||||||
| 13 | |||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||
| 15 | |||||||||||
| 16 | =head1 DESCRIPTION | ||||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | =head1 NOTE | ||||||||||
| 20 | |||||||||||
| 21 | This is alpha software! Read the status section in the package README | ||||||||||
| 22 | or on the L<website|http://functional-perl.org/>. | ||||||||||
| 23 | |||||||||||
| 24 | =cut | ||||||||||
| 25 | |||||||||||
| 26 | package Chj::Unix::Exitcode; | ||||||||||
| 27 | 80 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 80 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 80 | ▶ | use warnings FATAL => 'uninitialized'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | 80 | ▶ | use Exporter "import"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 31 | |||||||||||
| 32 | 80 | our @EXPORT = qw(exitcode); | |||||||||
| 33 | 80 | our @EXPORT_OK = qw(exitcode); | |||||||||
| 34 | 80 | our %EXPORT_TAGS = (all => \@EXPORT_OK); | |||||||||
| 35 | |||||||||||
| 36 | 80 | ▶ | use FP::Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 37 | |||||||||||
| 38 | 80 | package Chj::Unix::Exitcode::Exitcode { | |||||||||
| 39 | |||||||||||
| 40 | 80 | ▶ | use Chj::Unix::Signal; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 41 | |||||||||||
| 42 | 80 | ▶ | use Chj::Class::Array -fields => -publica => 'code', | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 43 | 80 | ; | |||||||||
| 44 | |||||||||||
| 45 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||
| 46 | 0 | my $class = shift; | |||||||||
| 47 | 0 | my $s = $class->SUPER::new; | |||||||||
| 48 | 0 | ($$s[Code]) = @_; | |||||||||
| 49 | 0 | $s | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | sub as_string { | ||||||||
|
Subroutine
as_string: not called CC=3 SCAR=24.8
| |||||||||||
| 53 | 0 | my $s = shift; | |||||||||
| 54 | 0 | my $code = $$s[Code]; | |||||||||
| 55 | 0 | ▶ | if ($code < 256) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 0 | "signal $code (" . Chj::Unix::Signal->new($code)->as_string . ")" | |||||||||
| 57 | } else { | ||||||||||
| 58 | 0 | ▶ | if (($code & 255) == 0) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 0 | "exit value " . ($code >> 8) | |||||||||
| 60 | } else { | ||||||||||
| 61 | 0 | warn "does this ever happen?"; | |||||||||
| 62 | 0 | "both exit value and signal ($code)" | |||||||||
| 63 | } | ||||||||||
| 64 | } | ||||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 80 | end Chj::Class::Array; | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 0 | ▶ | sub exitcode { | ||||||||
|
Subroutine
exitcode: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 71 | 0 | ▶ | @_ == 1 or fp_croak_arity 1; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | 0 | my ($code) = @_; | |||||||||
| 73 | 0 | Chj::Unix::Exitcode::Exitcode->new($code)->as_string; | |||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | 80 | 1 | |||||||||