blib/lib/ClearCase/ClearPrompt.pm

filter: Statementstmt 18.0% 67 / 372 Branchbran 8.7% 24 / 276 Conditioncond 6.8% 13 / 190 MC/DCmcdc 0.0% 0 / 109 Subroutinesub 36.8% 7 / 19 Podpod 0.0% 0 / 11 totaltotal 11.3% 111 / 977 CC 204 SCAR 67.9
CC
204
Cov
12%
import
1791.7
clearprompt
1550.0
redirect
506.0
CRAP 892.4
↑ Summary
1 package ClearCase::ClearPrompt;
2  
3 1 require 5.001;
4  
5 1 $VERSION = $VERSION = '1.31';
6 1 @EXPORT_OK = qw(clearprompt clearprompt_dir redirect tempname die
7 $CT $TriggerSeries
8 );
9  
10 1 %EXPORT_TAGS = ( 'all' => [ qw(
11 clearprompt
12 clearprompt_dir
13 redirect
14 tempname
15 ) ] );
16  
17 1 require Exporter;
18 1 @ISA = qw(Exporter);
19  
20 # Conceptually this is "use constant MSWIN ..." but ccperl can't do that.
21 2 ▶sub MSWIN { ($^O || $ENV{OS}) =~ /MSWin32|Windows_NT/i ? 1 : 0 }
Subroutine MSWIN: called CC=3 SCAR=14.2
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
($^O || $ENV{'OS'}) =~ /MSWin32|Windows_NT/i ? : 0 2 2
Condition33%1/3
$^O || $ENV{'OS'}
l!l&&r!l&&!r
200
MC/DC0%0/2
$^O || $ENV{'OS'}
$^O $ENV{'OS'}
Truth table33%1/3
A || B
A= $^OB= $ENV{'OS'}
ABresult
1X1
011
000
22  
23 1 ▶use vars qw($TriggerSeries $StashFile);
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 $TriggerSeries = $ENV{CLEARCASE_CLEARPROMPT_TRIGGERSERIES};
25  
26 # Make $CT read-only but not a constant so it can be interpolated.
27 1 *CT = *CT = \ccpath('cleartool'); # double assignment suppresses warning
28  
29 1 ▶if ($] > 5.004) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] > "5.004") 1 0 1
30 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 ▶ eval "use subs 'die'"; # We override this and may also export it to caller
Subroutine BEGIN: called CC=1 SCAR=0.0
32 }
33  
34 1 my %Dialogs = ();
35 1 my %Mailings = ();
36 1 my %MailTo = (); # accumulates lists of users to mail various msgs to.
37  
38 1 (my $prog = $0) =~ s%.*[/\\]%%;
39  
40 0 ▶sub rerun_in_debug_mode {
Subroutine rerun_in_debug_mode: not called CC=8 SCAR=42.8
Pod undocumented
41 # Re-exec ourself with debugging turned on. If in GUI mode,
42 # rerun in a new window. This allows "perl -d" debugging of
43 # triggers in a GUI env.
44 0 delete $ENV{CLEARCASE_CLEARPROMPT_DEBUG}; # suppress recursion
45 0 ▶ return if $ENV{PERL_DL_NONLAZY}; # marker for 'make test'
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PERL_DL_NONLAZY"} 0 0 0
46 0 my @cmd = ($^X, '-d', $0, @ARGV);
47 0 ▶ if (MSWIN()) {
Branch: 1 branch
BranchTrueFalseTotal
if (MSWIN()) { } 0 0 0
48 0 for (@cmd) {
49 0 ▶ $_ = qq("$_") if m%\s%;
Branch: 1 branch
BranchTrueFalseTotal
if /\s/ 0 0 0
50 }
51 0 ▶ unshift(@cmd, qw(start /wait)) if $ENV{ATRIA_FORCE_GUI};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"ATRIA_FORCE_GUI"} 0 0 0
52 } else {
53 0 ▶ unshift(@cmd, qw(xterm -e)) if $ENV{ATRIA_FORCE_GUI};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"ATRIA_FORCE_GUI"} 0 0 0
54 }
55 0 ▶ if (MSWIN()) {
Branch: 1 branch
BranchTrueFalseTotal
if (MSWIN()) { } 0 0 0
56 # This does not work with ccperl (5.001) if CC is installed to
57 # "C:\Program Files\...".
58 0 my $rc = system(@cmd);
59 0 exit($rc != 0);
60 } else {
61 0 exec(@cmd);
62 }
63 }
64  
65 0 ▶sub dbg_shell {
Subroutine dbg_shell: not called CC=8 SCAR=42.8
Pod undocumented
66 # Fork an interactive shell and wait for it. Useful in triggers because
67 # it lets you explore the runtime environment of the trigger script.
68 0 ▶ return if $ENV{PERL_DL_NONLAZY}; # marker for 'make test'
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PERL_DL_NONLAZY"} 0 0 0
69 0 my $cmd = $ENV{CLEARCASE_CLEARPROMPT_DEBUG_SHELL};
70 0 ▶ $cmd = MSWIN() ? $ENV{COMSPEC} : '/bin/sh' unless $cmd && -x $cmd;
Branch: 2 branches
BranchTrueFalseTotal
unless $cmd and -x $cmd 0 0 0
MSWIN() ? : 0 0 0
Condition0%0/3
$cmd and -x $cmd
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd and -x $cmd
$cmd -x $cmd
Truth table0%0/3
A and B
A= $cmdB= -x $cmd
ABresult
0X0
100
111
71 0 ▶ if ($ENV{ATRIA_FORCE_GUI}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"ATRIA_FORCE_GUI"}) 0 0 0
72 0 ▶ if (MSWIN()) {
Branch: 1 branch
BranchTrueFalseTotal
if (MSWIN()) { } 0 0 0
73 0 $cmd = "start /wait $cmd";
74 } else {
75 0 $cmd = "xterm -e $cmd";
76 }
77 }
78 0 ▶ exit 1 if system $cmd;
Branch: 1 branch
BranchTrueFalseTotal
if system $cmd 0 0 0
79 }
80  
81 # Debugging aids. Documented in POD section. These can also be
82 # controlled via cmds at import time.
83 1 ▶if ($ENV{CLEARCASE_CLEARPROMPT_DEBUG} ||
Branch: 2 branches
BranchTrueFalseTotal
if ($ENV{'CLEARCASE_CLEARPROMPT_DEBUG'} or $ENV{'ATRIA_FORCE_GUI'} and $ENV{'PERL5OPT'} and $ENV{'PERL5OPT'} =~ /-d/) { } 0 1 1
elsif ($ENV{'CLEARCASE_CLEARPROMPT_DEBUG_SHELL'}) { } 0 1 1
Condition33%3/9
$ENV{"CLEARCASE_CLEARPROMPT_DEBUG"} or $ENV{"ATRIA_FORCE_GUI"} and $ENV{"PERL5OPT"} and $ENV{"PERL5OPT"} =~ /-d/
l!l&&r!l&&!r
001
$ENV{"ATRIA_FORCE_GUI"} and $ENV{"PERL5OPT"} and $ENV{"PERL5OPT"} =~ /-d/
!ll&&!rl&&r
100
$ENV{"ATRIA_FORCE_GUI"} and $ENV{"PERL5OPT"}
!ll&&!rl&&r
100
MC/DC0%0/4
$ENV{"CLEARCASE_CLEARPROMPT_DEBUG"} or $ENV{"ATRIA_FORCE_GUI"} and $ENV{"PERL5OPT"} and $ENV{"PERL5OPT"} =~ /-d/
$ENV{"CLEARCASE_CLEARPROMPT_DEBUG"} $ENV{"ATRIA_FORCE_GUI"} $ENV{"PERL5OPT"} $ENV{"PERL5OPT"} =~ /-d/
Truth table20%1/5
A or B and C and D
A= $ENV{"CLEARCASE_CLEARPROMPT_DEBUG"}B= $ENV{"ATRIA_FORCE_GUI"}C= $ENV{"PERL5OPT"}D= $ENV{"PERL5OPT"} =~ /-d/
ABCDresult
1XXX1
01111
00XX0
010X0
01100
84 ($ENV{ATRIA_FORCE_GUI} && $ENV{PERL5OPT} && $ENV{PERL5OPT} =~ /-d/)) {
85 0 rerun_in_debug_mode();
86 } elsif ($ENV{CLEARCASE_CLEARPROMPT_DEBUG_SHELL}) {
87 0 dbg_shell();
88 }
89  
90 # Make an attempt to supply a full path to the specified program.
91 # Else fall back to relying on PATH.
92 1 ▶sub ccpath {
Subroutine ccpath: called CC=3 SCAR=12.5
Pod undocumented
93 1 my $name = shift;
94 1 ▶ if (MSWIN()) {
Branch: 1 branch
BranchTrueFalseTotal
if (MSWIN()) { } 0 1 1
95 0 return $name; # no way to avoid relying on PATH in &^&@$! Windows
96 } else {
97 1 ▶ return join('/', $ENV{ATRIAHOME} || q(/usr/atria), 'bin', $name);
Condition50%1/2
$ENV{'ATRIAHOME'} || '/usr/atria'
l!l
01
MC/DC0%0/1
$ENV{'ATRIAHOME'} || '/usr/atria'
$ENV{'ATRIAHOME'}
Truth table50%1/2
A
A= $ENV{'ATRIAHOME'}
Aresult
11
00
98 }
99 }
100  
101 # Generates a random-ish name for a temp file that doesn't yet exist.
102 # This function makes no pretense of being atomic; it's conceivable,
103 # though highly unlikely, that the generated filename could be
104 # taken between the time it's generated and the time it's used.
105 # The optional parameter becomes a filename extension. The optional
106 # 2nd parameter overrides the basename part of the generated path.
107 0 ▶sub tempname {
Subroutine tempname: not called CC=9 SCAR=45.0
Pod undocumented
108 0 my($custom, $tmpf) = @_;
109 # The preferred directory for temp files.
110 my $tmpd = MSWIN() ?
111 ($ENV{TEMP} || $ENV{TMP} || ( -d "$ENV{SYSTEMDRIVE}/temp" ?
112 "$ENV{SYSTEMDRIVE}/temp" : $ENV{SYSTEMDRIVE})) :
113 0 ▶ ($ENV{TMPDIR} || '/tmp');
Branch: 2 branches
BranchTrueFalseTotal
MSWIN() ? : 0 0 0
-d "$ENV{'SYSTEMDRIVE'}/temp" ? : 0 0 0
Condition0%0/8
$ENV{"TEMP"} or $ENV{"TMP"} or -d qq[$ENV{"SYSTEMDRIVE"}/temp] ? qq[$ENV{"SYSTEMDRIVE"}/temp] : $ENV{"SYSTEMDRIVE"}
l!l&&r!l&&!r
000
$ENV{"TEMP"} or $ENV{"TMP"}
l!l&&r!l&&!r
000
$ENV{"TMPDIR"} or "/tmp"
l!l
00
MC/DC0%0/3
$ENV{"TEMP"} or $ENV{"TMP"} or -d qq[$ENV{"SYSTEMDRIVE"}/temp] ? qq[$ENV{"SYSTEMDRIVE"}/temp] : $ENV{"SYSTEMDRIVE"}
$ENV{"TEMP"} $ENV{"TMP"} -d qq[$ENV{"SYSTEMDRIVE"}/temp] ? qq[$ENV{"SYSTEMDRIVE"}/temp] : $ENV{"SYSTEMDRIVE"}
MC/DC0%0/1
$ENV{"TMPDIR"} or "/tmp"
$ENV{"TMPDIR"}
Truth table0%0/4
A or B or C
A= $ENV{"TEMP"}B= $ENV{"TMP"}C= -d qq[$ENV{"SYSTEMDRIVE"}/temp] ? qq[$ENV{"SYSTEMDRIVE"}/temp] : $ENV{"SYSTEMDRIVE"}
ABCresult
1XX1
01X1
0011
0000
Truth table0%0/2
A
A= $ENV{"TMPDIR"}
Aresult
11
00
114 0 $tmpd =~ s%\\%/%g;
115 0 my $ext = 'tmp';
116 0 ▶ return "$tmpd/$tmpf.$custom.$ext" if $tmpf;
Branch: 1 branch
BranchTrueFalseTotal
if $tmpf 0 0 0
117 0 (my $pkg = lc __PACKAGE__) =~ s/:+/-/g;
118 0 while (1) {
119 0 $tmpf = join('.', "$tmpd/$pkg", $$, int(rand 10000));
120 0 ▶ $tmpf .= $custom ? ".$custom.$ext" : ".$ext";
Branch: 1 branch
BranchTrueFalseTotal
$custom ? : 0 0 0
121 0 ▶ return $tmpf if ! -f $tmpf;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $tmpf 0 0 0
122 }
123 }
124  
125 # Run clearprompt with specified args and return what it returned. Uses the
126 # exact same syntax as the clearprompt executable ('ct man clearprompt')
127 # except for -outfile <file> which is handled internally here.
128 0 ▶sub clearprompt {
Subroutine clearprompt: not called CC=40 SCAR=73.5
Pod undocumented
129 0 my $mode = shift;
130 0 my @args = @_;
131 0 my $data;
132  
133 0 ▶ return 0 if $ENV{ATRIA_WEB_GUI}; # must assume "" or 0 if ccweb interface
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"ATRIA_WEB_GUI"} 0 0 0
134  
135 0 local $!; # don't mess up errno in the caller's world.
136  
137 # Play back responses from the StashFile if it exists and other conditions
138 # are satisfied. It seems that CC sets the series id to all zeroes
139 # after an error condition (??) so we avoid that case explicitly.
140 0 my $lineno = (caller)[2];
141 0 my $subtext = "from $prog:$lineno";
142 0 ▶ if ($TriggerSeries && $ENV{CLEARCASE_SERIES_ID} &&
Branch: 1 branch
BranchTrueFalseTotal
if ($TriggerSeries and $ENV{"CLEARCASE_SERIES_ID"} and not $ENV{"CLEARCASE_SERIES_ID"} =~ /^[0:.]+$/) 0 0 0
Condition0%0/6
$TriggerSeries and $ENV{"CLEARCASE_SERIES_ID"} and not $ENV{"CLEARCASE_SERIES_ID"} =~ /^[0:.]+$/
!ll&&!rl&&r
000
$TriggerSeries and $ENV{"CLEARCASE_SERIES_ID"}
!ll&&!rl&&r
000
MC/DC0%0/3
$TriggerSeries and $ENV{"CLEARCASE_SERIES_ID"} and not $ENV{"CLEARCASE_SERIES_ID"} =~ /^[0:.]+$/
$TriggerSeries $ENV{"CLEARCASE_SERIES_ID"} not $ENV{"CLEARCASE_SERIES_ID"} =~ /^[0:.]+$/
Truth table0%0/4
A and B and not(C)
A= $TriggerSeriesB= $ENV{"CLEARCASE_SERIES_ID"}C= not $ENV{"CLEARCASE_SERIES_ID"} =~ /^[0:.]+$/
ABCresult
0XX0
10X0
1100
1111
143 $ENV{CLEARCASE_SERIES_ID} !~ /^[0:.]+$/) {
144 0 (my $sid = $ENV{CLEARCASE_SERIES_ID}) =~ s%:+%-%g;
145 0 $StashFile = tempname($prog, "CLEARCASE_SERIES_ID=$sid");
146 0 ▶ if (!$ENV{CLEARCASE_BEGIN_SERIES} && -f $StashFile) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $ENV{"CLEARCASE_BEGIN_SERIES"} and -f $StashFile) 0 0 0
Condition0%0/3
not $ENV{"CLEARCASE_BEGIN_SERIES"} and -f $StashFile
!ll&&!rl&&r
000
MC/DC0%0/2
not $ENV{"CLEARCASE_BEGIN_SERIES"} and -f $StashFile
not $ENV{"CLEARCASE_BEGIN_SERIES"} -f $StashFile
Truth table0%0/3
not(A) and B
A= not $ENV{"CLEARCASE_BEGIN_SERIES"}B= -f $StashFile
ABresult
0X0
100
111
147 0 do $StashFile;
148 0 ▶ if ($ENV{CLEARCASE_END_SERIES} &&
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"CLEARCASE_END_SERIES"} and not $ENV{"CLEARCASE_CLEARPROMPT_KEEP_CAPTURE"}) 0 0 0
Condition0%0/3
$ENV{"CLEARCASE_END_SERIES"} and not $ENV{"CLEARCASE_CLEARPROMPT_KEEP_CAPTURE"}
!ll&&!rl&&r
000
MC/DC0%0/2
$ENV{"CLEARCASE_END_SERIES"} and not $ENV{"CLEARCASE_CLEARPROMPT_KEEP_CAPTURE"}
$ENV{"CLEARCASE_END_SERIES"} not $ENV{"CLEARCASE_CLEARPROMPT_KEEP_CAPTURE"}
Truth table0%0/3
A and not(B)
A= $ENV{"CLEARCASE_END_SERIES"}B= not $ENV{"CLEARCASE_CLEARPROMPT_KEEP_CAPTURE"}
ABresult
0X0
100
111
149 !$ENV{CLEARCASE_CLEARPROMPT_KEEP_CAPTURE}) {
150 # We delay the unlink due to weird Windows locking behavior
151 0 eval "END { unlink '$StashFile' }";
152 }
153 1 ▶ no strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
154 0 my $data = eval "\$stash$lineno";
155 0 ▶ _automail('PROMPT', "Replay $subtext", "REPLAY:\n",
Branch: 1 branch
BranchTrueFalseTotal
defined $data ? : 0 0 0
156 defined($data) ? $data : 'undef');
157 0 return $data;
158 }
159 }
160  
161 # On Windows we must add an extra level of escaping to any args
162 # which might have special chars since all forms of system()
163 # appear to go through the %^%@# cmd shell (boo!). This is
164 # also handled by Perl 5.6.1, ActiveState build 630 but it will
165 # be a long time till we can count on that fix being present.
166 0 ▶ if (MSWIN()) {
Branch: 1 branch
BranchTrueFalseTotal
if (MSWIN()) 0 0 0
167 0 for (0..$#args) {
168 0 my $i = $_;
169 0 ▶ if ($args[$i] =~ /^-(?:pro|ite|def|dfi|dir)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args[$i] =~ /^-(?:pro|ite|def|dfi|dir)/) 0 0 0
170 0 $args[$i+1] =~ s/"/'/gs;
171 0 $args[$i+1] = qq("$args[$i+1]");
172 }
173 }
174 }
175  
176 # For clearprompt modes in which we get textual data back via a file,
177 # derive here a reasonable temp-file name and handle the details
178 # of reading the data out of it and unlinking it when done.
179 # For other modes, just fire off the cmd and return the status.
180 # In a void context, don't wait for the button to be pushed; just
181 # "fork" and proceed asynchonously since this is presumably just an
182 # informational message.
183 # If the cmd took a signal, return undef and leave the signal # in $?.
184 0 ▶ if ($mode =~ /text|file|list/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /text|file|list/) { } 0 0 0
185 0 my $outf = tempname($mode);
186 0 my @cmd = (ccpath('clearprompt'), $mode, '-out', $outf, @args);
187 0 ▶ print STDERR "+ @cmd\n" if $ClearCase::ClearPrompt::Verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $Verbose 0 0 0
188 0 ▶ if (!system(@cmd)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not system(@cmd)) { } 0 0 0
189 0 ▶ if (open(OUTFILE, $outf)) {
Branch: 1 branch
BranchTrueFalseTotal
if (open OUTFILE, $outf) 0 0 0
190 0 local $/ = undef;
191 0 $data = <OUTFILE>;
192 0 ▶ $data = '' if !defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 0 0
193 0 close(OUTFILE);
194 }
195 } else {
196 # If we took a signal, return undef with the signal # in $?. The
197 # clearprompt cmd apparently catches SIGINT and returns 0x400 for
198 # some reason; we fix it here so $? looks like a normal sig2.
199 0 ▶ $? = 2 if $? == 0x400;
Branch: 1 branch
BranchTrueFalseTotal
if $? == 1024 0 0 0
200 0 ▶ $data = undef if $? && $? <= 0x80;
Branch: 1 branch
BranchTrueFalseTotal
if $? and $? <= 128 0 0 0
Condition0%0/3
$? and $? <= 128
!ll&&!rl&&r
000
MC/DC0%0/2
$? and $? <= 128
$? $? <= 128
Truth table0%0/3
A and B
A= $?B= $? <= 128
ABresult
0X0
100
111
201 }
202 0 ▶ unlink $outf if -f $outf;
Branch: 1 branch
BranchTrueFalseTotal
if -f $outf 0 0 0
203 0 ▶ _automail('PROMPT', "Prompt $subtext", "PROMPT:\n", "@cmd\n",
Branch: 1 branch
BranchTrueFalseTotal
defined $data ? : 0 0 0
204 "\nRESPONSE:\n", defined($data) ? $data : 'undef');
205 } else {
206 0 my @cmd = (ccpath('clearprompt'), $mode, @args);
207 0 ▶ print STDERR "+ @cmd\n" if $ClearCase::ClearPrompt::Verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $Verbose 0 0 0
208 0 ▶ if (defined wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined wantarray) { } 0 0 0
209 0 system(@cmd);
210 0 ▶ $? = 2 if $? == 0x400; # see above
Branch: 1 branch
BranchTrueFalseTotal
if $? == 1024 0 0 0
211 0 ▶ $data = ($? && $? <= 0x80) ? undef : $?>>8;
Branch: 1 branch
BranchTrueFalseTotal
$? && $? <= 128 ? : 0 0 0
Condition0%0/3
$? and $? <= 128
!ll&&!rl&&r
000
MC/DC0%0/2
$? and $? <= 128
$? $? <= 128
Truth table0%0/3
A and B
A= $?B= $? <= 128
ABresult
0X0
100
111
212 0 ▶ _automail('PROMPT', "Prompt $subtext", "PROMPT:\n",
Branch: 1 branch
BranchTrueFalseTotal
defined $data ? : 0 0 0
213 "@cmd\n", "\nRESPONSE:\n", defined($data) ? $data : 'undef');
214 } else {
215 0 _automail('PROMPT', "Prompt $subtext", "PROMPT:\n", "@cmd\n");
216 0 ▶ if (MSWIN()) {
Branch: 2 branches
BranchTrueFalseTotal
if (MSWIN()) { } 0 0 0
elsif (exists $ENV{'DISPLAY'}) { } 0 0 0
217 # Windows (always) GUI - fork new thread to run async
218 0 system(1, @cmd);
219 0 return;
220 } elsif (exists $ENV{DISPLAY}) {
221 # Unix GUI - must fork to run async
222 0 ▶ return if fork;
Branch: 1 branch
BranchTrueFalseTotal
if fork 0 0 0
223 0 exec(@cmd);
224 } else {
225 # Unix cmd line - must close stdin to run async
226 0 open(SAVE_STDIN, ">&STDIN");
227 0 close(STDIN);
228 0 system(@cmd);
229 0 open(STDIN, ">&SAVE_STDIN");
230 0 close(SAVE_STDIN);
231 }
232 }
233 }
234  
235 # Record responses if $TriggerSeries is turned on.
236 0 ▶ if ($StashFile) {
Branch: 1 branch
BranchTrueFalseTotal
if ($StashFile) 0 0 0
237 0 ▶ if ($ENV{CLEARCASE_BEGIN_SERIES} && !$ENV{CLEARCASE_END_SERIES}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"CLEARCASE_BEGIN_SERIES"} and not $ENV{"CLEARCASE_END_SERIES"}) 0 0 0
Condition0%0/3
$ENV{"CLEARCASE_BEGIN_SERIES"} and not $ENV{"CLEARCASE_END_SERIES"}
!ll&&!rl&&r
000
MC/DC0%0/2
$ENV{"CLEARCASE_BEGIN_SERIES"} and not $ENV{"CLEARCASE_END_SERIES"}
$ENV{"CLEARCASE_BEGIN_SERIES"} not $ENV{"CLEARCASE_END_SERIES"}
Truth table0%0/3
A and not(B)
A= $ENV{"CLEARCASE_BEGIN_SERIES"}B= not $ENV{"CLEARCASE_END_SERIES"}
ABresult
0X0
100
111
238 0 my $top = ! -f $StashFile;
239 0 eval { require Data::Dumper };
240 0 ▶ if ($@ || $] < 5.004) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or $] < 5.004) { } 0 0 0
Condition0%0/3
$@ or $] < "5.004"
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ or $] < "5.004"
$@ $] < "5.004"
Truth table0%0/3
A or B
A= $@B= $] < "5.004"
ABresult
1X1
011
000
241 0 warn "$prog: Warning: TriggerSeries requires Data::Dumper\n";
242 } else {
243 0 ▶ open(STASH, ">>$StashFile") || die "$prog: $StashFile: $!";
Branch: 1 branch
BranchTrueFalseTotal
open STASH, ">>$StashFile" or CORE::die "${prog}: ${StashFile}: $!" 0 0 0
244 0 ▶ print STASH "# This file contains data stashed for $prog\n"
Branch: 1 branch
BranchTrueFalseTotal
if $top 0 0 0
245 if $top;
246 0 print STASH Data::Dumper->new([$data], ["stash$lineno"])->Dump;
247 0 close(STASH);
248 0 ▶ if (! $ENV{CLEARCASE_CLEARPROMPT_KEEP_CAPTURE}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ENV{"CLEARCASE_CLEARPROMPT_KEEP_CAPTURE"}) 0 0 0
249 0 ▶ $SIG{INT} = sub { unlink $StashFile };
Subroutine __ANON__: not called CC=1 SCAR=6.9
250 }
251 }
252 }
253 }
254  
255 0 return $data;
256 }
257  
258 # Fake up a directory chooser using opendir/readdir/closedir and
259 # 'clearprompt list'.
260 0 ▶sub clearprompt_dir {
Subroutine clearprompt_dir: not called CC=15 SCAR=54.8
Pod undocumented
261 0 require Cwd;
262 0 require File::Spec;
263 0 my($dir, $msg) = @_;
264 0 my(%subdirs, $items, @drives);
265 0 my $iwd = Cwd::abs_path('.');
266 0 ▶ $dir = $iwd if $dir eq '.';
Branch: 1 branch
BranchTrueFalseTotal
if $dir eq "." 0 0 0
267  
268 0 ▶ return 0 if $ENV{ATRIA_WEB_GUI}; # must assume "" or 0 if ccweb interface
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"ATRIA_WEB_GUI"} 0 0 0
269  
270 0 while (1) {
271 0 ▶ if (opendir(DIR, $dir)) {
Branch: 1 branch
BranchTrueFalseTotal
if (opendir DIR, $dir) { } 0 0 0
272 0 ▶ %subdirs = map {$_ => 1} grep {-d "$dir/$_" || ! -e "$dir/$_"}
Condition0%0/3
-d "$dir/$_" || !(-e "$dir/$_")
l!l&&r!l&&!r
000
MC/DC0%0/2
-d "$dir/$_" || !(-e "$dir/$_")
-d "$dir/$_" !(-e "$dir/$_")
Truth table0%0/3
A || not(B)
A= -d "$dir/$_"B= !(-e "$dir/$_")
ABresult
1X1
011
000
273 readdir(DIR);
274 0 chomp %subdirs;
275 0 closedir(DIR);
276 } else {
277 0 warn "$dir: $!\n";
278 0 $dir = File::Spec->rootdir;
279 0 next;
280 }
281 0 ▶ if (MSWIN() && $dir =~ m%^[A-Z]:[\\/]?$%i) {
Branch: 1 branch
BranchTrueFalseTotal
if (MSWIN() and $dir =~ m[^[A-Z]:[\\/]?$]i) { } 0 0 0
Condition0%0/3
MSWIN() and $dir =~ m[^[A-Z]:[\\/]?$]i
!ll&&!rl&&r
000
MC/DC0%0/2
MSWIN() and $dir =~ m[^[A-Z]:[\\/]?$]i
MSWIN() $dir =~ m[^[A-Z]:[\\/]?$]i
Truth table0%0/3
A and B
A= MSWIN()B= $dir =~ m[^[A-Z]:[\\/]?$]i
ABresult
0X0
100
111
282 0 delete $subdirs{'.'};
283 0 delete $subdirs{'..'};
284 0 ▶ @drives = grep {-e} map {"$_:"} 'C'..'Z' if !@drives;
Branch: 1 branch
BranchTrueFalseTotal
unless @drives 0 0 0
285 0 $items = join(',', @drives, sort keys %subdirs);
286 } else {
287 0 $items = join(',', sort keys %subdirs);
288 }
289 0 my $resp = clearprompt(qw(list -items), $items,
290 '-pro', "$msg [ $dir ]");
291 0 ▶ if (!defined $resp) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $resp) 0 0 0
292 0 undef $dir;
293 0 last;
294 }
295 0 chomp $resp;
296 0 ▶ last if ! $resp || $resp eq '.';
Branch: 1 branch
BranchTrueFalseTotal
if not $resp or $resp eq "." 0 0 0
Condition0%0/3
not $resp or $resp eq "."
l!l&&r!l&&!r
000
MC/DC0%0/2
not $resp or $resp eq "."
not $resp $resp eq "."
Truth table0%0/3
not(A) or B
A= not $respB= $resp eq "."
ABresult
1X1
011
000
297 0 ▶ if (MSWIN() && $resp =~ m%^[A-Z]:[\\/]?$%i) {
Branch: 1 branch
BranchTrueFalseTotal
if (MSWIN() and $resp =~ m[^[A-Z]:[\\/]?$]i) { } 0 0 0
Condition0%0/3
MSWIN() and $resp =~ m[^[A-Z]:[\\/]?$]i
!ll&&!rl&&r
000
MC/DC0%0/2
MSWIN() and $resp =~ m[^[A-Z]:[\\/]?$]i
MSWIN() $resp =~ m[^[A-Z]:[\\/]?$]i
Truth table0%0/3
A and B
A= MSWIN()B= $resp =~ m[^[A-Z]:[\\/]?$]i
ABresult
0X0
100
111
298 0 $dir = $resp;
299 0 ▶ chdir $dir || warn "$dir: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
chdir $dir or warn "${dir}: $!\n" 0 0 0
300 } else {
301 0 $dir = Cwd::abs_path(File::Spec->catdir($dir, $resp));
302 }
303 }
304 0 ▶ chdir $iwd || warn "$iwd: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
chdir $iwd or warn "${iwd}: $!\n" 0 0 0
305 0 return $dir;
306 }
307  
308 # Takes args in the form "redirect(STDERR => 'OFF', STDOUT => 'ON')" and
309 # enables or disables stdout/stderr as specified.
310 0 ▶sub redirect {
Subroutine redirect: not called CC=22 SCAR=62.3
Pod undocumented
311 # Stash these away at first use for potential future use, e.g. debugging.
312 0 ▶ open(SAVE_STDOUT, '>&STDOUT') if !defined fileno(SAVE_STDOUT);
Branch: 1 branch
BranchTrueFalseTotal
unless defined fileno SAVE_STDOUT 0 0 0
313 0 ▶ open(SAVE_STDERR, '>&STDERR') if !defined fileno(SAVE_STDERR);
Branch: 1 branch
BranchTrueFalseTotal
unless defined fileno SAVE_STDERR 0 0 0
314  
315 0 ▶ while(@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
316 0 my $stream = uc shift;
317 0 my $state = shift;
318  
319 0 ▶ if ($stream ne 'STDOUT' && $stream ne 'STDERR') {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream ne "STDOUT" and $stream ne "STDERR") 0 0 0
Condition0%0/3
$stream ne "STDOUT" and $stream ne "STDERR"
!ll&&!rl&&r
000
MC/DC0%0/2
$stream ne "STDOUT" and $stream ne "STDERR"
$stream ne "STDOUT" $stream ne "STDERR"
Truth table0%0/3
A and B
A= $stream ne "STDOUT"B= $stream ne "STDERR"
ABresult
0X0
100
111
320 0 print SAVE_STDERR "unrecognized stream $stream\n";
321 0 next;
322 }
323  
324 0 ▶ if ($stream eq 'STDOUT') {
Branch: 2 branches
BranchTrueFalseTotal
if ($stream eq 'STDOUT') { } 0 0 0
elsif ($stream eq 'STDERR') { } 0 0 0
325 0 ▶ if ($state =~ /^OFF$/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($state =~ /^OFF$/i) { } 0 0 0
elsif ($state =~ /^ON$/i) { } 0 0 0
326 0 ▶ if (defined fileno(STDOUT)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined fileno STDOUT) 0 0 0
327 0 ▶ open(HIDE_STDOUT, '>&STDOUT')
Branch: 1 branch
BranchTrueFalseTotal
unless defined fileno HIDE_STDOUT 0 0 0
328 if !defined fileno(HIDE_STDOUT);
329 0 close(STDOUT);
330 }
331 } elsif ($state =~ /^ON$/i) {
332 0 open(STDOUT, '>&HIDE_STDOUT');
333 } else {
334 0 ▶ if (defined fileno(STDOUT)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined fileno STDOUT) 0 0 0
335 0 ▶ open(HIDE_STDOUT, '>&STDOUT')
Branch: 1 branch
BranchTrueFalseTotal
unless defined fileno HIDE_STDOUT 0 0 0
336 if !defined fileno(HIDE_STDOUT);
337 0 ▶ open(STDOUT, $state) || warn "$state: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
open STDOUT, $state or warn "${state}: $!\n" 0 0 0
338 }
339 }
340 } elsif ($stream eq 'STDERR') {
341 0 ▶ if ($state =~ /^OFF$/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($state =~ /^OFF$/i) { } 0 0 0
elsif ($state =~ /^ON$/i) { } 0 0 0
342 0 ▶ if (defined fileno(STDERR)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined fileno STDERR) 0 0 0
343 0 ▶ open(HIDE_STDERR, '>&STDERR')
Branch: 1 branch
BranchTrueFalseTotal
unless defined fileno HIDE_STDERR 0 0 0
344 if !defined fileno(HIDE_STDERR);
345 0 close(STDERR);
346 }
347 } elsif ($state =~ /^ON$/i) {
348 0 open(STDERR, '>&HIDE_STDERR');
349 } else {
350 0 ▶ if (defined fileno(STDERR)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined fileno STDERR) 0 0 0
351 0 ▶ open(HIDE_STDERR, '>&STDERR')
Branch: 1 branch
BranchTrueFalseTotal
unless defined fileno HIDE_STDERR 0 0 0
352 if !defined fileno(HIDE_STDERR);
353 0 ▶ open(STDERR, $state) || warn "$state: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
open STDERR, $state or warn "${state}: $!\n" 0 0 0
354 }
355 }
356 }
357 }
358 }
359  
360 # Called like this "sendmsg([<to-list>], $subject, @body_of_message)".
361 # I.e. a ref to a list of email addresses followed by a string
362 # scalar containing the subject. Remaining parameters are used
363 # as the body of the message. Returns true on successful delivery
364 # of msg to the MTA.
365 0 ▶sub sendmsg {
Subroutine sendmsg: not called CC=18 SCAR=58.3
Pod undocumented
366 0 my($r_to, $subj, @body) = @_;
367 # If no mailto list, no mail.
368 0 ▶ return 1 unless @$r_to;
Branch: 1 branch
BranchTrueFalseTotal
unless @$r_to 0 0 0
369  
370 # Only drag Net::SMTP in at runtime since it's not core perl.
371 0 eval { require Net::SMTP };
372 0 ▶ if (! $@) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($@) 0 0 0
373 0 ▶ my $name = $ENV{CLEARCASE_USER} || $ENV{USERNAME} || $ENV{LOGNAME};
Condition0%0/6
$ENV{'CLEARCASE_USER'} || $ENV{'USERNAME'} || $ENV{'LOGNAME'}
l!l&&r!l&&!r
000
$ENV{"CLEARCASE_USER"} or $ENV{"USERNAME"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$ENV{'CLEARCASE_USER'} || $ENV{'USERNAME'} || $ENV{'LOGNAME'}
$ENV{"CLEARCASE_USER"} $ENV{"USERNAME"} $ENV{'LOGNAME'}
Truth table0%0/4
A or B || C
A= $ENV{"CLEARCASE_USER"}B= $ENV{"USERNAME"}C= $ENV{'LOGNAME'}
ABCresult
1XX1
01X1
0011
0000
374 0 my $smtp;
375 0 eval { $smtp = Net::SMTP->new };
376 0 ▶ if ($smtp) {
Branch: 1 branch
BranchTrueFalseTotal
if ($smtp) 0 0 0
377 0 local $^W = 0; # hide a spurious warning from deep in Net::SMTP
378 0 ▶ $smtp->mail($name) &&
Branch: 1 branch
BranchTrueFalseTotal
$smtp->mail($name) and $smtp->to(@$r_to, {"SkipBad", 1}) and $smtp->data and $smtp->datasend("To: @$r_to\n") and $smtp->datasend("Subject: $subj\n") and $smtp->datasend(join(" ", "X-Mailer:", __PACKAGE__, $VERSION)) and $smtp->datasend("\n") and $smtp->datasend(@body) and $smtp->dataend and $smtp->quit and return 1 0 0 0
Condition0%0/27
$smtp->mail($name) and $smtp->to(@$r_to, {"SkipBad", 1}) and $smtp->data and $smtp->datasend("To: @$r_to\n") and $smtp->datasend("Subject: $subj\n") and $smtp->datasend(join(" ", "X-Mailer:", __PACKAGE__, $VERSION)) and $smtp->datasend("\n") and $smtp->datasend(@body) and $smtp->dataend and $smtp->quit
!ll&&!rl&&r
000
$smtp->mail($name) and $smtp->to(@$r_to, {"SkipBad", 1}) and $smtp->data and $smtp->datasend("To: @$r_to\n") and $smtp->datasend("Subject: $subj\n") and $smtp->datasend(join(" ", "X-Mailer:", __PACKAGE__, $VERSION)) and $smtp->datasend("\n") and $smtp->datasend(@body) and $smtp->dataend
!ll&&!rl&&r
000
$smtp->mail($name) and $smtp->to(@$r_to, {"SkipBad", 1}) and $smtp->data and $smtp->datasend("To: @$r_to\n") and $smtp->datasend("Subject: $subj\n") and $smtp->datasend(join(" ", "X-Mailer:", __PACKAGE__, $VERSION)) and $smtp->datasend("\n") and $smtp->datasend(@body)
!ll&&!rl&&r
000
$smtp->mail($name) and $smtp->to(@$r_to, {"SkipBad", 1}) and $smtp->data and $smtp->datasend("To: @$r_to\n") and $smtp->datasend("Subject: $subj\n") and $smtp->datasend(join(" ", "X-Mailer:", __PACKAGE__, $VERSION)) and $smtp->datasend("\n")
!ll&&!rl&&r
000
$smtp->mail($name) and $smtp->to(@$r_to, {"SkipBad", 1}) and $smtp->data and $smtp->datasend("To: @$r_to\n") and $smtp->datasend("Subject: $subj\n") and $smtp->datasend(join(" ", "X-Mailer:", __PACKAGE__, $VERSION))
!ll&&!rl&&r
000
$smtp->mail($name) and $smtp->to(@$r_to, {"SkipBad", 1}) and $smtp->data and $smtp->datasend("To: @$r_to\n") and $smtp->datasend("Subject: $subj\n")
!ll&&!rl&&r
000
$smtp->mail($name) and $smtp->to(@$r_to, {"SkipBad", 1}) and $smtp->data and $smtp->datasend("To: @$r_to\n")
!ll&&!rl&&r
000
$smtp->mail($name) and $smtp->to(@$r_to, {"SkipBad", 1}) and $smtp->data
!ll&&!rl&&r
000
$smtp->mail($name) and $smtp->to(@$r_to, {"SkipBad", 1})
!ll&&!rl&&r
000
MC/DC0%0/10
$smtp->mail($name) and $smtp->to(@$r_to, {"SkipBad", 1}) and $smtp->data and $smtp->datasend("To: @$r_to\n") and $smtp->datasend("Subject: $subj\n") and $smtp->datasend(join(" ", "X-Mailer:", __PACKAGE__, $VERSION)) and $smtp->datasend("\n") and $smtp->datasend(@body) and $smtp->dataend and $smtp->quit
$smtp->mail($name) $smtp->to(@$r_to, {"SkipBad", 1}) $smtp->data $smtp->datasend("To: @$r_to\n") $smtp->datasend("Subject: $subj\n") $smtp->datasend(join(" ", "X-Mailer:", __PACKAGE__, $VERSION)) $smtp->datasend("\n") $smtp->datasend(@body) $smtp->dataend $smtp->quit
Truth table0%0/11
A and B and C and D and E and F and G and H and I and J
A= $smtp->mail($name)B= $smtp->to(@$r_to, {"SkipBad", 1})C= $smtp->dataD= $smtp->datasend("To: @$r_to\n")E= $smtp->datasend("Subject: $subj\n")F= $smtp->datasend(join(" ", "X-Mailer:", __PACKAGE__, $VERSION))G= $smtp->datasend("\n")H= $smtp->datasend(@body)I= $smtp->dataendJ= $smtp->quit
ABCDEFGHIJresult
0XXXXXXXXX0
10XXXXXXXX0
110XXXXXXX0
1110XXXXXX0
11110XXXXX0
111110XXXX0
1111110XXX0
11111110XX0
111111110X0
11111111100
11111111111
379 $smtp->to(@$r_to, {SkipBad => 1}) &&
380 $smtp->data() &&
381 $smtp->datasend("To: @$r_to\n") &&
382 $smtp->datasend("Subject: $subj\n") &&
383 $smtp->datasend(join(' ', 'X-Mailer:',__PACKAGE__,$VERSION)) &&
384 $smtp->datasend("\n") &&
385 $smtp->datasend(@body) &&
386 $smtp->dataend() &&
387 $smtp->quit &&
388 return 1; # succeeded, so return
389 }
390 }
391  
392 # If Net::SMTP isn't installed or didn't work, try notify.exe
393 0 ▶ my $nexe = MSWIN() ? 'notify' : '/usr/atria/bin/notify';
Branch: 1 branch
BranchTrueFalseTotal
MSWIN() ? : 0 0 0
394 my $notify = qq($nexe -l triggers -s "$subj" ) .
395 0 join(' ', map {qq("$_")} @$r_to);
396 0 ▶ if (open(NOTIFY, "| $notify")) {
Branch: 1 branch
BranchTrueFalseTotal
if (open NOTIFY, "| $notify") 0 0 0
397 0 print NOTIFY @body;
398 0 return close(NOTIFY);
399 }
400 0 return 0; # failure
401 }
402  
403 # A private wrapper over sendmsg() to reformat the subj/msg
404 # appropriately for error message captures.
405 0 ▶sub _automail {
Subroutine _automail: not called CC=5 SCAR=34.0
406 0 ▶ return 0 if defined $ENV{CLEARCASE_CLEARPROMPT_NO_SENDMSG};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ENV{"CLEARCASE_CLEARPROMPT_NO_SENDMSG"} 0 0 0
407 0 my $type = shift;
408 0 ▶ return unless exists $MailTo{$type} && $MailTo{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $MailTo{$type} and $MailTo{$type} 0 0 0
Condition0%0/3
exists $MailTo{$type} and $MailTo{$type}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $MailTo{$type} and $MailTo{$type}
exists $MailTo{$type} $MailTo{$type}
Truth table0%0/3
A and B
A= exists $MailTo{$type}B= $MailTo{$type}
ABresult
0X0
100
111
409 0 my $addrs = $MailTo{$type};
410 0 my $subj = shift;
411 # We don't need Sys::Hostname except in this situation, so ...
412 0 eval { require Sys::Hostname; };
413 0 ▶ $subj .= ' on ' . Sys::Hostname::hostname() unless $@;
Branch: 1 branch
BranchTrueFalseTotal
unless $@ 0 0 0
414 0 $subj .= ' via ClearCase::ClearPrompt';
415 0 sendmsg($addrs, $subj, @_);
416 }
417  
418 # Warning: significant hackery here. Basically, normal-looking symbol
419 # names are passed on to the Exporter import method as usual, whereas
420 # names of the form /WORD or +WORD or +WORD=<list> are commands which
421 # cause special behavior within this routine. All commands start with
422 # '/', such as /TRIGGERSERIES and /ENV. Captures start with '+' and
423 # include +{CAPTURE,ERRORS,WARN,DIE,STDOUT,STDERR}. If the capture
424 # name has a list of users attached, eg "+STDERR=user1,user2,..",
425 # the captured messages are sent via email to the specified users.
426 # Use +CAPTURE=<list> to email messages from all channels to <list>.
427 ## Apologies to anyone trying to read this ... it's a real mess, due
428 ## mostly to my attempts to stay compatible with earler versions which
429 ## may not have involved the best design decisions.
430 1 my($tmpout, $tmperr); # these must be here for scoping reasons
431 1 ▶sub import {
Subroutine import: called CC=59 SCAR=74.9
432 # First remember the entire parameter list.
433 1 my @p = @_;
434  
435 # Then separate it into "normal-looking" symbols to export into
436 # caller's namespace, "captures" which describe channels we need
437 # to arrange to capture here, and "commands" to deal with otherwise.
438 # Also, provide our own implementation of export tags for qw(:all).
439 # I'd prefer not to support that any more but do for back compat.
440 1 my %exports = map { $_ => 1 } grep !m%^[+/:]%, @p;
441 0 my %tags = map {substr($_, 1) => 1} grep m%^:%, @p;
442 1 my %caps = map {m%^.(\w+)=?(.*)%; $1 => $2} grep m%^\+%, @p;
443 0 my %cmds = map {m%^.(\w+)%; $1 => 1} grep m%^/%, @p;
444  
445 # Allow trigger series stashing to be turned on at import time,
446 # but let the EV override. We allow '+TRIGGERSERIES' for
447 # compatibility but '/TRIGGERSERIES' is preferred.
448 1 ▶ if (exists($cmds{TRIGGERSERIES}) || exists($caps{TRIGGERSERIES})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $cmds{"TRIGGERSERIES"} or exists $caps{"TRIGGERSERIES"}) 1 0 1
Condition33%1/3
exists $cmds{"TRIGGERSERIES"} or exists $caps{"TRIGGERSERIES"}
l!l&&r!l&&!r
010
MC/DC0%0/2
exists $cmds{"TRIGGERSERIES"} or exists $caps{"TRIGGERSERIES"}
exists $cmds{"TRIGGERSERIES"} exists $caps{"TRIGGERSERIES"}
Truth table33%1/3
A or B
A= exists $cmds{"TRIGGERSERIES"}B= exists $caps{"TRIGGERSERIES"}
ABresult
1X1
011
000
449 1 ▶ $cmds{TRIGGERSERIES} ||= $caps{TRIGGERSERIES};
Condition33%1/3
$cmds{"TRIGGERSERIES"} ||= $caps{"TRIGGERSERIES"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$cmds{"TRIGGERSERIES"} ||= $caps{"TRIGGERSERIES"}
$cmds{"TRIGGERSERIES"} $caps{"TRIGGERSERIES"}
Truth table33%1/3
A ||= B
A= $cmds{"TRIGGERSERIES"}B= $caps{"TRIGGERSERIES"}
ABresult
1X1
011
000
450 1 delete $caps{TRIGGERSERIES};
451 $ClearCase::ClearPrompt::TriggerSeries = 1
452 1 ▶ if !exists($ENV{CLEARCASE_CLEARPROMPT_TRIGGERSERIES});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ENV{"CLEARCASE_CLEARPROMPT_TRIGGERSERIES"} 1 0 1
453 }
454  
455 # If requested to via '/ENV', modify all CLEARCASE_* EV's which
456 # use back (\) slashes such that they use forward (/) slashes
457 # instead, assuming that these will refer to pathnames or parts
458 # of pathnames, perhaps in MVFS space (e.g. CLEARCASE_VERSION_ID).
459 1 ▶ if (MSWIN() && exists($cmds{ENV})) {
Branch: 1 branch
BranchTrueFalseTotal
if (MSWIN() and exists $cmds{"ENV"}) 0 1 1
Condition33%1/3
MSWIN() and exists $cmds{"ENV"}
!ll&&!rl&&r
100
MC/DC0%0/2
MSWIN() and exists $cmds{"ENV"}
MSWIN() exists $cmds{"ENV"}
Truth table33%1/3
A and B
A= MSWIN()B= exists $cmds{"ENV"}
ABresult
0X0
100
111
460 0 for (keys %ENV) {
461 0 ▶ $ENV{$_} =~ s%\\%/%g if m%^CLEARCASE_%;
Branch: 1 branch
BranchTrueFalseTotal
if /^CLEARCASE_/ 0 0 0
462 }
463 }
464  
465 # The user may request via /DEBUG that the script (typically a trigger)
466 # be rerun in debug mode. See POD.
467 1 ▶ rerun_in_debug_mode() if exists($cmds{DEBUG});
Branch: 1 branch
BranchTrueFalseTotal
if exists $cmds{"DEBUG"} 0 1 1
468  
469 # The user may request via /SHELL that the script (typically a trigger)
470 # fork an interactive shell so its runtime env can be explored.
471 1 ▶ dbg_shell() if exists($cmds{SHELL});
Branch: 1 branch
BranchTrueFalseTotal
if exists $cmds{"SHELL"} 0 1 1
472  
473 # Allow this EV to override the capture list.
474 1 ▶ if ($ENV{CLEARCASE_CLEARPROMPT_CAPTURE_LIST}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"CLEARCASE_CLEARPROMPT_CAPTURE_LIST"}) 0 1 1
475 0 @p = split /\s+/, $ENV{CLEARCASE_CLEARPROMPT_CAPTURE_LIST};
476 0 %caps = map {m%^.(\w+)=?(.*)%; $1 => $2} grep /^\+/, @p;
477 0 for (split /\s+/, @p) {
478 0 m%^.(\w+)=?(.*)%;
479 0 $caps{$1} = $2;
480 }
481 }
482  
483 # Now divide capture requests into those for dialog boxes and
484 # those for mailings.
485 1 %Dialogs = map {substr($_, 1) => 1} grep /^\+\w+$/, @p;
486 0 %Mailings = map {m%^.(\w+)=(.*)%; $1 => $2 } grep /^\+\w+=/, @p;
487  
488 # If :tags were requested, map them to their predefined export lists.
489 1 for (keys %tags) {
490 0 my $tag = $_;
491 0 ▶ next unless $EXPORT_TAGS{$tag};
Branch: 1 branch
BranchTrueFalseTotal
unless $EXPORT_TAGS{$tag} 0 0 0
492 0 for (@{$EXPORT_TAGS{$tag}}) {
493 0 $exports{$_} = 1;
494 }
495 }
496  
497 # Export the die func if its corresponding channel was requested.
498 $exports{'die'} = 1 if exists($caps{DIE}) ||
499 1 ▶ exists($caps{CAPTURE}) || exists($caps{ERRORS});
Branch: 1 branch
BranchTrueFalseTotal
if exists $caps{"DIE"} or exists $caps{"CAPTURE"} or exists $caps{"ERRORS"} 0 1 1
Condition33%2/6
exists $caps{"DIE"} or exists $caps{"CAPTURE"} or exists $caps{"ERRORS"}
l!l&&r!l&&!r
001
exists $caps{"DIE"} or exists $caps{"CAPTURE"}
l!l&&r!l&&!r
001
MC/DC0%0/3
exists $caps{"DIE"} or exists $caps{"CAPTURE"} or exists $caps{"ERRORS"}
exists $caps{"DIE"} exists $caps{"CAPTURE"} exists $caps{"ERRORS"}
Truth table25%1/4
A or B or C
A= exists $caps{"DIE"}B= exists $caps{"CAPTURE"}C= exists $caps{"ERRORS"}
ABCresult
1XX1
01X1
0011
0000
500  
501 # Set up the override hook for warn() if requested.
502 $SIG{__WARN__} = \&cpwarn if exists($caps{WARN}) ||
503 1 ▶ exists($caps{CAPTURE}) || exists($caps{ERRORS});
Branch: 1 branch
BranchTrueFalseTotal
if exists $caps{"WARN"} or exists $caps{"CAPTURE"} or exists $caps{"ERRORS"} 0 1 1
Condition33%2/6
exists $caps{"WARN"} or exists $caps{"CAPTURE"} or exists $caps{"ERRORS"}
l!l&&r!l&&!r
001
exists $caps{"WARN"} or exists $caps{"CAPTURE"}
l!l&&r!l&&!r
001
MC/DC0%0/3
exists $caps{"WARN"} or exists $caps{"CAPTURE"} or exists $caps{"ERRORS"}
exists $caps{"WARN"} exists $caps{"CAPTURE"} exists $caps{"ERRORS"}
Truth table25%1/4
A or B or C
A= exists $caps{"WARN"}B= exists $caps{"CAPTURE"}C= exists $caps{"ERRORS"}
ABCresult
1XX1
01X1
0011
0000
504  
505 # Export the non-cmd symbols, which may include die().
506 1 my @shares = grep {!/:/} keys %exports;
507 1 ▶ if ($] <= 5.001) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] <= 5.001) { } 0 1 1
508 # This weird hackery needed for ccperl (5.001) ...
509 0 my $caller = caller;
510 0 ▶ $caller = 'main' if $caller eq 'DB'; # hack for ccperl -d bug
Branch: 1 branch
BranchTrueFalseTotal
if $caller eq "DB" 0 0 0
511 0 for (@shares) {
512 0 ▶ if (s/^(\W)//) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^(\W)//) { } 0 0 0
513 0 eval "*{$caller\::$_} = \\$1$_";
514 } else {
515 0 *{"$caller\::$_"} = \&$_;
516 }
517 }
518 } else {
519 # ... and this "normal" hackery is for modern perls.
520 1 __PACKAGE__->export_to_level(1, $p[0], @shares);
521 }
522  
523 # +CAPTURE grabs all forms of output while +ERRORS grabs only error
524 # forms (meaning everything but stdout). NOTE: we must be very careful
525 # about the fact that there may be keys which EXIST but whose
526 # values are UNDEFINED.
527 1 ▶ if (exists($Dialogs{CAPTURE})) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $Dialogs{'CAPTURE'}) { } 0 1 1
elsif (exists $Dialogs{'ERRORS'}) { } 0 1 1
528 0 ▶ $Dialogs{WARN} ||= $Dialogs{CAPTURE};
Condition0%0/3
$Dialogs{"WARN"} ||= $Dialogs{"CAPTURE"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Dialogs{"WARN"} ||= $Dialogs{"CAPTURE"}
$Dialogs{"WARN"} $Dialogs{"CAPTURE"}
Truth table0%0/3
A ||= B
A= $Dialogs{"WARN"}B= $Dialogs{"CAPTURE"}
ABresult
1X1
011
000
529 0 ▶ $Dialogs{DIE} ||= $Dialogs{CAPTURE};
Condition0%0/3
$Dialogs{"DIE"} ||= $Dialogs{"CAPTURE"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Dialogs{"DIE"} ||= $Dialogs{"CAPTURE"}
$Dialogs{"DIE"} $Dialogs{"CAPTURE"}
Truth table0%0/3
A ||= B
A= $Dialogs{"DIE"}B= $Dialogs{"CAPTURE"}
ABresult
1X1
011
000
530 0 ▶ $Dialogs{STDERR} ||= $Dialogs{CAPTURE};
Condition0%0/3
$Dialogs{"STDERR"} ||= $Dialogs{"CAPTURE"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Dialogs{"STDERR"} ||= $Dialogs{"CAPTURE"}
$Dialogs{"STDERR"} $Dialogs{"CAPTURE"}
Truth table0%0/3
A ||= B
A= $Dialogs{"STDERR"}B= $Dialogs{"CAPTURE"}
ABresult
1X1
011
000
531 0 ▶ $Dialogs{STDOUT} ||= $Dialogs{CAPTURE};
Condition0%0/3
$Dialogs{"STDOUT"} ||= $Dialogs{"CAPTURE"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Dialogs{"STDOUT"} ||= $Dialogs{"CAPTURE"}
$Dialogs{"STDOUT"} $Dialogs{"CAPTURE"}
Truth table0%0/3
A ||= B
A= $Dialogs{"STDOUT"}B= $Dialogs{"CAPTURE"}
ABresult
1X1
011
000
532 0 delete $Dialogs{CAPTURE};
533 } elsif (exists($Dialogs{ERRORS})) {
534 0 ▶ $Dialogs{WARN} ||= $Dialogs{ERRORS};
Condition0%0/3
$Dialogs{"WARN"} ||= $Dialogs{"ERRORS"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Dialogs{"WARN"} ||= $Dialogs{"ERRORS"}
$Dialogs{"WARN"} $Dialogs{"ERRORS"}
Truth table0%0/3
A ||= B
A= $Dialogs{"WARN"}B= $Dialogs{"ERRORS"}
ABresult
1X1
011
000
535 0 ▶ $Dialogs{DIE} ||= $Dialogs{ERRORS};
Condition0%0/3
$Dialogs{"DIE"} ||= $Dialogs{"ERRORS"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Dialogs{"DIE"} ||= $Dialogs{"ERRORS"}
$Dialogs{"DIE"} $Dialogs{"ERRORS"}
Truth table0%0/3
A ||= B
A= $Dialogs{"DIE"}B= $Dialogs{"ERRORS"}
ABresult
1X1
011
000
536 0 ▶ $Dialogs{STDERR} ||= $Dialogs{ERRORS};
Condition0%0/3
$Dialogs{"STDERR"} ||= $Dialogs{"ERRORS"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Dialogs{"STDERR"} ||= $Dialogs{"ERRORS"}
$Dialogs{"STDERR"} $Dialogs{"ERRORS"}
Truth table0%0/3
A ||= B
A= $Dialogs{"STDERR"}B= $Dialogs{"ERRORS"}
ABresult
1X1
011
000
537 0 delete $Dialogs{ERRORS};
538 }
539 1 ▶ if (exists($Mailings{CAPTURE})) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $Mailings{'CAPTURE'}) { } 0 1 1
elsif (exists $Mailings{'ERRORS'}) { } 0 1 1
540 0 ▶ $Mailings{WARN} ||= $Mailings{CAPTURE};
Condition0%0/3
$Mailings{"WARN"} ||= $Mailings{"CAPTURE"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Mailings{"WARN"} ||= $Mailings{"CAPTURE"}
$Mailings{"WARN"} $Mailings{"CAPTURE"}
Truth table0%0/3
A ||= B
A= $Mailings{"WARN"}B= $Mailings{"CAPTURE"}
ABresult
1X1
011
000
541 0 ▶ $Mailings{DIE} ||= $Mailings{CAPTURE};
Condition0%0/3
$Mailings{"DIE"} ||= $Mailings{"CAPTURE"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Mailings{"DIE"} ||= $Mailings{"CAPTURE"}
$Mailings{"DIE"} $Mailings{"CAPTURE"}
Truth table0%0/3
A ||= B
A= $Mailings{"DIE"}B= $Mailings{"CAPTURE"}
ABresult
1X1
011
000
542 0 ▶ $Mailings{STDERR} ||= $Mailings{CAPTURE};
Condition0%0/3
$Mailings{"STDERR"} ||= $Mailings{"CAPTURE"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Mailings{"STDERR"} ||= $Mailings{"CAPTURE"}
$Mailings{"STDERR"} $Mailings{"CAPTURE"}
Truth table0%0/3
A ||= B
A= $Mailings{"STDERR"}B= $Mailings{"CAPTURE"}
ABresult
1X1
011
000
543 0 ▶ $Mailings{STDOUT} ||= $Mailings{CAPTURE};
Condition0%0/3
$Mailings{"STDOUT"} ||= $Mailings{"CAPTURE"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Mailings{"STDOUT"} ||= $Mailings{"CAPTURE"}
$Mailings{"STDOUT"} $Mailings{"CAPTURE"}
Truth table0%0/3
A ||= B
A= $Mailings{"STDOUT"}B= $Mailings{"CAPTURE"}
ABresult
1X1
011
000
544 0 delete $Mailings{CAPTURE};
545 } elsif (exists($Mailings{ERRORS})) {
546 0 ▶ $Mailings{WARN} ||= $Mailings{ERRORS};
Condition0%0/3
$Mailings{"WARN"} ||= $Mailings{"ERRORS"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Mailings{"WARN"} ||= $Mailings{"ERRORS"}
$Mailings{"WARN"} $Mailings{"ERRORS"}
Truth table0%0/3
A ||= B
A= $Mailings{"WARN"}B= $Mailings{"ERRORS"}
ABresult
1X1
011
000
547 0 ▶ $Mailings{DIE} ||= $Mailings{ERRORS};
Condition0%0/3
$Mailings{"DIE"} ||= $Mailings{"ERRORS"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Mailings{"DIE"} ||= $Mailings{"ERRORS"}
$Mailings{"DIE"} $Mailings{"ERRORS"}
Truth table0%0/3
A ||= B
A= $Mailings{"DIE"}B= $Mailings{"ERRORS"}
ABresult
1X1
011
000
548 0 ▶ $Mailings{STDERR} ||= $Mailings{ERRORS};
Condition0%0/3
$Mailings{"STDERR"} ||= $Mailings{"ERRORS"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Mailings{"STDERR"} ||= $Mailings{"ERRORS"}
$Mailings{"STDERR"} $Mailings{"ERRORS"}
Truth table0%0/3
A ||= B
A= $Mailings{"STDERR"}B= $Mailings{"ERRORS"}
ABresult
1X1
011
000
549 0 delete $Mailings{ERRORS};
550 }
551  
552 # Set up the mailing lists for each channel as requested.
553 1 ▶ $MailTo{WARN} = [split /,/, $Mailings{WARN}] if $Mailings{WARN};
Branch: 1 branch
BranchTrueFalseTotal
if $Mailings{"WARN"} 0 1 1
554 1 ▶ $MailTo{DIE} = [split /,/, $Mailings{DIE}] if $Mailings{DIE};
Branch: 1 branch
BranchTrueFalseTotal
if $Mailings{"DIE"} 0 1 1
555 1 ▶ $MailTo{STDOUT} = [split /,/, $Mailings{STDOUT}] if $Mailings{STDOUT};
Branch: 1 branch
BranchTrueFalseTotal
if $Mailings{"STDOUT"} 0 1 1
556 1 ▶ $MailTo{STDERR} = [split /,/, $Mailings{STDERR}] if $Mailings{STDERR};
Branch: 1 branch
BranchTrueFalseTotal
if $Mailings{"STDERR"} 0 1 1
557 1 ▶ $MailTo{PROMPT} = [split /,/, $Mailings{PROMPT}] if $Mailings{PROMPT};
Branch: 1 branch
BranchTrueFalseTotal
if $Mailings{"PROMPT"} 0 1 1
558  
559 # Last, handle generic stdout and stderr unless the caller asks us not to.
560 1 ▶ if (exists($caps{STDOUT}) || exists($caps{STDERR})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $caps{"STDOUT"} or exists $caps{"STDERR"}) 0 1 1
Condition33%1/3
exists $caps{"STDOUT"} or exists $caps{"STDERR"}
l!l&&r!l&&!r
001
MC/DC0%0/2
exists $caps{"STDOUT"} or exists $caps{"STDERR"}
exists $caps{"STDOUT"} exists $caps{"STDERR"}
Truth table33%1/3
A or B
A= exists $caps{"STDOUT"}B= exists $caps{"STDERR"}
ABresult
1X1
011
000
561 0 $tmpout = tempname('stdout');
562 0 $tmperr = tempname('stderr');
563  
564 # Connect stdout and stderr to temp files for later use in END {}.
565 0 ▶ if (exists($caps{STDOUT}) && ($ENV{ATRIA_FORCE_GUI} || $caps{STDOUT})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $caps{"STDOUT"} and $ENV{"ATRIA_FORCE_GUI"} || $caps{"STDOUT"}) 0 0 0
Condition0%0/6
exists $caps{"STDOUT"} and $ENV{"ATRIA_FORCE_GUI"} || $caps{"STDOUT"}
!ll&&!rl&&r
000
$ENV{"ATRIA_FORCE_GUI"} or $caps{"STDOUT"}
l!l&&r!l&&!r
000
MC/DC0%0/3
exists $caps{"STDOUT"} and $ENV{"ATRIA_FORCE_GUI"} || $caps{"STDOUT"}
exists $caps{"STDOUT"} $ENV{"ATRIA_FORCE_GUI"} $caps{"STDOUT"}
Truth table0%0/4
A and B or C
A= exists $caps{"STDOUT"}B= $ENV{"ATRIA_FORCE_GUI"}C= $caps{"STDOUT"}
ABCresult
0XX0
1000
11X1
1011
566 0 open(HOLDOUT, '>&STDOUT');
567 0 ▶ open(STDOUT, ">$tmpout") || warn "$tmpout: $!";
Branch: 1 branch
BranchTrueFalseTotal
open STDOUT, ">$tmpout" or warn "${tmpout}: $!" 0 0 0
568 }
569 0 ▶ if (exists($caps{STDERR}) && ($ENV{ATRIA_FORCE_GUI} || $caps{STDERR})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $caps{"STDERR"} and $ENV{"ATRIA_FORCE_GUI"} || $caps{"STDERR"}) 0 0 0
Condition0%0/6
exists $caps{"STDERR"} and $ENV{"ATRIA_FORCE_GUI"} || $caps{"STDERR"}
!ll&&!rl&&r
000
$ENV{"ATRIA_FORCE_GUI"} or $caps{"STDERR"}
l!l&&r!l&&!r
000
MC/DC0%0/3
exists $caps{"STDERR"} and $ENV{"ATRIA_FORCE_GUI"} || $caps{"STDERR"}
exists $caps{"STDERR"} $ENV{"ATRIA_FORCE_GUI"} $caps{"STDERR"}
Truth table0%0/4
A and B or C
A= exists $caps{"STDERR"}B= $ENV{"ATRIA_FORCE_GUI"}C= $caps{"STDERR"}
ABCresult
0XX0
1000
11X1
1011
570 0 open(HOLDERR, '>&STDERR');
571 0 ▶ open(STDERR, ">$tmperr") || warn "$tmperr: $!";
Branch: 1 branch
BranchTrueFalseTotal
open STDERR, ">$tmperr" or warn "${tmperr}: $!" 0 0 0
572 }
573  
574 # After program finishes, collect any stdout/stderr and display
575 # with clearprompt and/or mail it out.
576 0 ▶ sub endfunc {
Subroutine endfunc: not called CC=19 SCAR=59.4
Pod undocumented
577 # retain original exit code on stack
578 0 my $rc = $?;
579 0 local $?;
580  
581 # Restore stdout and stderr to their original fd's.
582 0 ▶ if (defined fileno HOLDOUT) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined fileno HOLDOUT) 0 0 0
583 0 open(STDOUT, '>&HOLDOUT');
584 0 close(HOLDOUT);
585 }
586 0 ▶ if (defined fileno HOLDERR) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined fileno HOLDERR) 0 0 0
587 0 open(STDERR, '>&HOLDERR');
588 0 close(HOLDERR);
589 }
590  
591 # Then display any stdout we captured in a dialog box.
592 0 ▶ if (defined($tmpout) && -e $tmpout) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tmpout and -e $tmpout) 0 0 0
Condition0%0/3
defined $tmpout and -e $tmpout
!ll&&!rl&&r
000
MC/DC0%0/2
defined $tmpout and -e $tmpout
defined $tmpout -e $tmpout
Truth table0%0/3
A and B
A= defined $tmpoutB= -e $tmpout
ABresult
0X0
100
111
593 0 ▶ open(OUT, $tmpout) || warn "$prog: $tmpout: $!";
Branch: 1 branch
BranchTrueFalseTotal
open OUT, $tmpout or warn "${prog}: ${tmpout}: $!" 0 0 0
594 0 my @msg = <OUT>;
595 0 close(OUT);
596 0 ▶ if (@msg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@msg) 0 0 0
597 0 _automail('STDOUT', "Stdout from $prog", @msg);
598 0 ▶ if ($Dialogs{STDOUT}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Dialogs{"STDOUT"}) 0 0 0
599 0 my $t = "STDOUT\n\n @msg";
600 0 clearprompt(qw(proceed -type o -mask p -pref -pro), $t);
601 }
602 }
603 0 ▶ if (!$ENV{CLEARCASE_CLEARPROMPT_KEEP_CAPTURE}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ENV{"CLEARCASE_CLEARPROMPT_KEEP_CAPTURE"}) 0 0 0
604 # On Windows, we can't unlink this tempfile while
605 # any asynchronous dialog boxes are still on the
606 # screen due to threading/locking design, so we
607 # give the user some time to read & close them.
608 0 ▶ if (MSWIN()) {
Branch: 1 branch
BranchTrueFalseTotal
if (MSWIN()) { } 0 0 0
609 0 system(1, qq($^X -e "sleep 30; unlink '$tmpout'"));
610 } else {
611 0 ▶ unlink($tmpout) || print "$prog: $tmpout: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
unlink $tmpout or print "${prog}: ${tmpout}: $!\n" 0 0 0
612 }
613 }
614 }
615 # Same as above but for stderr.
616 0 ▶ if (defined($tmperr) && -e $tmperr) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tmperr and -e $tmperr) 0 0 0
Condition0%0/3
defined $tmperr and -e $tmperr
!ll&&!rl&&r
000
MC/DC0%0/2
defined $tmperr and -e $tmperr
defined $tmperr -e $tmperr
Truth table0%0/3
A and B
A= defined $tmperrB= -e $tmperr
ABresult
0X0
100
111
617 0 my @msg;
618 {
619 0 ▶ open(ERR, $tmperr) || warn "$prog: $tmperr: $!";
Branch: 1 branch
BranchTrueFalseTotal
open ERR, $tmperr or warn "${prog}: ${tmperr}: $!" 0 0 0
620 0 local $^W = 0; # <ERR> gives bogus error with AS build 623
621 0 @msg = <ERR>;
622 0 close(ERR);
623 }
624 0 ▶ if (@msg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@msg) 0 0 0
625 0 _automail('STDERR', "Stderr from $prog", @msg);
626 0 ▶ if ($Dialogs{STDERR}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Dialogs{"STDERR"}) 0 0 0
627 0 my $t = "STDERR\n\n @msg";
628 0 clearprompt(qw(proceed -type o -mask p -pref -pro), $t);
629 }
630 }
631 0 ▶ if (!$ENV{CLEARCASE_CLEARPROMPT_KEEP_CAPTURE}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $ENV{"CLEARCASE_CLEARPROMPT_KEEP_CAPTURE"}) 0 0 0
632 0 ▶ if (MSWIN()) {
Branch: 1 branch
BranchTrueFalseTotal
if (MSWIN()) { } 0 0 0
633 0 system(1, qq($^X -e "sleep 30; unlink '$tmperr'"));
634 } else {
635 0 ▶ unlink($tmperr) || print "$prog: $tmperr: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
unlink $tmperr or print "${prog}: ${tmperr}: $!\n" 0 0 0
636 }
637 }
638 }
639 };
640 0 eval "END { endfunc(); }";
641 }
642 }
643  
644 # This is a pseudo warn() func which is called via the $SIG{__WARN__} hook.
645 0 ▶sub cpwarn {
Subroutine cpwarn: not called CC=4 SCAR=30.0
Pod undocumented
646 0 my @msg = @_;
647 # always show line numbers if this dbg flag set
648 0 ▶ if ($ENV{CLEARCASE_CLEARPROMPT_SHOW_LINENO}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"CLEARCASE_CLEARPROMPT_SHOW_LINENO"}) 0 0 0
649 0 my($file, $line) = (caller)[1,2];
650 0 chomp $msg[-1];
651 0 push(@msg, " at $file line $line.\n");
652 }
653 0 _automail('WARN', "Warning from $prog", @msg);
654 0 ▶ if ($ENV{ATRIA_FORCE_GUI} && $Dialogs{WARN}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'ATRIA_FORCE_GUI'} and $Dialogs{'WARN'}) { } 0 0 0
Condition0%0/3
$ENV{"ATRIA_FORCE_GUI"} and $Dialogs{"WARN"}
!ll&&!rl&&r
000
MC/DC0%0/2
$ENV{"ATRIA_FORCE_GUI"} and $Dialogs{"WARN"}
$ENV{"ATRIA_FORCE_GUI"} $Dialogs{"WARN"}
Truth table0%0/3
A and B
A= $ENV{"ATRIA_FORCE_GUI"}B= $Dialogs{"WARN"}
ABresult
0X0
100
111
655 0 clearprompt(qw(proceed -type w -mask p -pref -pro), "WARNING\n\n@msg");
656 0 return undef; # to keep clearprompt() in void context
657 } else {
658 0 warn @msg;
659 }
660 }
661  
662 # A pseudo die() which can be made to override the caller's builtin.
663 0 ▶sub die {
Subroutine die: not called CC=4 SCAR=30.0
664 0 my @msg = @_;
665 # always show line numbers if this dbg flag set
666 0 ▶ if ($ENV{CLEARCASE_CLEARPROMPT_SHOW_LINENO}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"CLEARCASE_CLEARPROMPT_SHOW_LINENO"}) 0 0 0
667 0 my($file, $line) = (caller)[1,2];
668 0 chomp $msg[-1];
669 0 push(@msg, " at $file line $line.\n");
670 }
671 0 _automail('DIE', "Error from $prog", @msg);
672 0 ▶ if ($ENV{ATRIA_FORCE_GUI} && $Dialogs{DIE}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'ATRIA_FORCE_GUI'} and $Dialogs{'DIE'}) { } 0 0 0
Condition0%0/3
$ENV{"ATRIA_FORCE_GUI"} and $Dialogs{"DIE"}
!ll&&!rl&&r
000
MC/DC0%0/2
$ENV{"ATRIA_FORCE_GUI"} and $Dialogs{"DIE"}
$ENV{"ATRIA_FORCE_GUI"} $Dialogs{"DIE"}
Truth table0%0/3
A and B
A= $ENV{"ATRIA_FORCE_GUI"}B= $Dialogs{"DIE"}
ABresult
0X0
100
111
673 0 clearprompt(qw(proceed -type e -mask p -pref -pro), "ERROR\n\n@msg");
674 0 exit $! || $?>>8 || 255; # suppress the msg to stderr
675 } else {
676 0 require Carp;
677 0 CORE::die Carp::shortmess(@_);
678  
679 }
680 }
681  
682 1 1;
683  
684 __END__
↑ Summary