line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IPC::PrettyPipe::Stream::Utils; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: support utilities for streams |
4
|
|
|
|
|
|
|
|
5
|
16
|
|
|
16
|
|
209082
|
use strict; |
|
16
|
|
|
|
|
38
|
|
|
16
|
|
|
|
|
460
|
|
6
|
16
|
|
|
16
|
|
79
|
use warnings; |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
706
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
9
|
|
|
|
|
|
|
|
10
|
16
|
|
|
16
|
|
5759
|
use parent 'Exporter'; |
|
16
|
|
|
|
|
4088
|
|
|
16
|
|
|
|
|
87
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw[ parse_spec ]; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub parse_spec { |
16
|
|
|
|
|
|
|
|
17
|
180
|
|
|
180
|
1
|
37839
|
my $op = shift; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# parse stream operator; shell syntax (similarity to IPC::Run's |
20
|
|
|
|
|
|
|
# syntax is no coincidence) |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# for consistency, N is always the descriptor which needs to |
23
|
|
|
|
|
|
|
# be opened or dup'ed to. M is never touched. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
return {} |
26
|
180
|
100
|
|
|
|
1448
|
unless $op =~ /^(?: |
27
|
|
|
|
|
|
|
# <, N< |
28
|
|
|
|
|
|
|
# >, N> |
29
|
|
|
|
|
|
|
# >>, N>> |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
(?'redirect' |
32
|
|
|
|
|
|
|
(?'N' \d+ (?!<<) )? # don't match N<< |
33
|
|
|
|
|
|
|
(?'Op' |
34
|
|
|
|
|
|
|
(?: [<>]{1,2} ) |
35
|
|
|
|
|
|
|
) |
36
|
|
|
|
|
|
|
) |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# >&, &> |
39
|
|
|
|
|
|
|
| (?'redirect_stdout_stderr' |
40
|
|
|
|
|
|
|
(?'Op' >& | &> ) |
41
|
|
|
|
|
|
|
) |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# N<&- |
44
|
|
|
|
|
|
|
| (?'close' |
45
|
|
|
|
|
|
|
(?'N' \d+ ) |
46
|
|
|
|
|
|
|
(?'Op' <& ) |
47
|
|
|
|
|
|
|
(?'M' - ) |
48
|
|
|
|
|
|
|
) |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# M<&N |
51
|
|
|
|
|
|
|
| (?'dup' |
52
|
|
|
|
|
|
|
(?'M' \d+ ) |
53
|
|
|
|
|
|
|
(?'Op' <& ) |
54
|
|
|
|
|
|
|
(?'N' \d+ ) |
55
|
|
|
|
|
|
|
) |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# N>&M |
58
|
|
|
|
|
|
|
| (?'dup' |
59
|
|
|
|
|
|
|
(?'N' \d+ ) |
60
|
|
|
|
|
|
|
(?'Op' >& ) |
61
|
|
|
|
|
|
|
(?'M' \d+ ) |
62
|
|
|
|
|
|
|
) |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
)$/x |
65
|
|
|
|
|
|
|
; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# force a copy of the hash; it's magical and a simple return |
68
|
|
|
|
|
|
|
# of the elements doesn't work. |
69
|
16
|
|
|
16
|
|
9371
|
my %opc = map { $_ => $+{$_} } grep { exists $+{$_} } qw[ N M Op ]; |
|
16
|
|
|
|
|
5688
|
|
|
16
|
|
|
|
|
2452
|
|
|
68
|
|
|
|
|
179
|
|
|
122
|
|
|
|
|
834
|
|
|
204
|
|
|
|
|
1082
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
( $opc{type} ) |
72
|
68
|
|
|
|
|
211
|
= grep { defined $+{$_} } qw[ redirect redirect_stdout_stderr close dup ]; |
|
272
|
|
|
|
|
1090
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# fill in default value for N for stdin & stdout |
75
|
|
|
|
|
|
|
$opc{N} = substr( $opc{Op}, 0, 1 ) eq '<' ? 0 : 1 |
76
|
68
|
100
|
100
|
|
|
545
|
if $+{redirect} && !defined $opc{N}; |
|
|
100
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$opc{param}++ |
79
|
68
|
100
|
100
|
|
|
476
|
if $+{redirect} || $+{redirect_stdout_stderr}; |
80
|
|
|
|
|
|
|
|
81
|
68
|
|
|
|
|
246
|
return \%opc; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# |
87
|
|
|
|
|
|
|
# This file is part of IPC-PrettyPipe |
88
|
|
|
|
|
|
|
# |
89
|
|
|
|
|
|
|
# This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory. |
90
|
|
|
|
|
|
|
# |
91
|
|
|
|
|
|
|
# This is free software, licensed under: |
92
|
|
|
|
|
|
|
# |
93
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
94
|
|
|
|
|
|
|
# |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |