if (*name == '|') {
/*SUPPRESS 530*/
for (name++; isSPACE(*name); name++) ;
+ if (*name == '\0') { /* command is missing 19990114 */
+ dTHR;
+ if (ckWARN(WARN_PIPE))
+ warner(WARN_PIPE, "Missing command in piped open");
+ errno = EPIPE;
+ goto say_false;
+ }
if (strNE(name,"-"))
TAINT_ENV();
TAINT_PROPER("piped open");
name[--len] = '\0';
/*SUPPRESS 530*/
for (; isSPACE(*name); name++) ;
+ if (*name == '\0') { /* command is missing 19990114 */
+ dTHR;
+ if (ckWARN(WARN_PIPE))
+ warner(WARN_PIPE, "Missing command in piped open");
+ errno = EPIPE;
+ goto say_false;
+ }
if (strNE(name,"-"))
TAINT_ENV();
TAINT_PROPER("piped open");
(W) You used a backslash-character combination which is not recognized
by Perl.
+=item Missing command in piped open
+
+(W) You used the C<open(FH, "| command")> or C<open(FH, "command |")>
+construction, but the command was missing or blank.
+
=head1 Obsolete Diagnostics
Todo.
(F) While certain functions allow you to specify a filehandle or an
"indirect object" before the argument list, this ain't one of them.
+=item Missing command in piped open
+
+(W) You used the C<open(FH, "| command")> or C<open(FH, "command |")>
+construction, but the command was missing or blank.
+
=item Missing operator before %s?
(S) This is an educated guess made in conjunction with the message "%s
}
$| = 1;
-print "1..12\n";
+print "1..14\n";
# External program 'tr' assumed.
open(PIPE, "|-") || (exec 'tr', 'YX', 'ko');
} else {
print "not ok 12\n# pid=$wait first=$pid pipe=$pipe zombie=$zombie me=$$ \$?=$? \$!=", $!+0, ":$!\n";
}
+
+# Test new semantics for missing command in piped open
+# 19990114 M-J. Dominus mjd@plover.com
+{ local *P;
+ print (((open P, "| " ) ? "not " : ""), "ok 13\n");
+ print (((open P, " |" ) ? "not " : ""), "ok 14\n");
+}
for (76..79) { print "ok $_ # Skipped: open('|') is not available\n" }
}
else {
- test 76, eval { open FOO, "| $foo" } eq '', 'popen to';
+ test 76, eval { open FOO, "| x$foo" } eq '', 'popen to';
test 77, $@ =~ /^Insecure dependency/, $@;
- test 78, eval { open FOO, "$foo |" } eq '', 'popen from';
+ test 78, eval { open FOO, "x$foo |" } eq '', 'popen from';
test 79, $@ =~ /^Insecure dependency/, $@;
}
Can't do bidirectional pipe
open(F, "| true |");
+ Missing command in piped open
+ open(F, "| ");
+
+ Missing command in piped open
+ open(F, " |");
+
warn(warn_nl, "open");
open(F, "true\ncd")
########
# doio.c
use warning 'io' ;
+open(F, "| ")
+EXPECT
+Missing command in piped open at - line 3.
+########
+# doio.c
+use warning 'io' ;
+open(F, " |")
+EXPECT
+Missing command in piped open at - line 3.
+########
+# doio.c
+use warning 'io' ;
open(F, "<true\ncd")
EXPECT
Unsuccessful open on filename containing newline at - line 3.