Skip to content

Commit 717a4f6

Browse files
committed
add test case for shell_exec() with $result_code set
1 parent 763deb4 commit 717a4f6

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
shell_exec() with exit code setting
3+
--SKIPIF--
4+
<?php
5+
if (!is_executable("/bin/true")) echo "skip";
6+
if (!function_exists("shell_exec")) echo "skip shell_exec() is not available";
7+
?>
8+
--FILE--
9+
<?php
10+
$retcode = null;
11+
12+
$commands = [
13+
"/bin/true",
14+
"non-existent-command > /dev/null 2>&1"
15+
];
16+
17+
foreach ($commands as $command) {
18+
shell_exec($command, $retcode);
19+
var_dump($retcode);
20+
}
21+
22+
echo "Done\n";
23+
?>
24+
--EXPECT--
25+
int(0)
26+
int(127)
27+
Done

0 commit comments

Comments
 (0)