xref: /php-src/sapi/cli/tests/021.phpt (revision dcc3255b)
1--TEST--
2CLI shell shebang
3--SKIPIF--
4<?php
5include 'skipif.inc';
6if (substr(PHP_OS, 0, 3) == 'WIN') {
7    die ("skip not for Windows");
8}
9
10if (str_contains(getenv('TEST_PHP_EXECUTABLE'), " ")) {
11    die("skip shebang cannot have spaces in its path");
12}
13
14if (strlen("#!".getenv('TEST_PHP_EXECUTABLE')) > 127) {
15        die ("skip shebang is too long, see http://www.in-ulm.de/~mascheck/various/shebang/#results");
16}
17?>
18--FILE--
19<?php
20
21$php = getenv('TEST_PHP_EXECUTABLE');
22
23$filename = __DIR__.'/021.tmp.php';
24
25$script = "#!$php -n\n".
26          "ola\n".
27          "<?php echo 1+1,'\n';\n".
28          "?>\n".
29          "adeus\n";
30
31file_put_contents($filename, $script);
32chmod($filename, 0777);
33
34echo `$filename`;
35
36echo "\nDone\n";
37?>
38--CLEAN--
39<?php
40unlink(__DIR__.'/021.tmp.php');
41?>
42--EXPECT--
43ola
442
45adeus
46
47Done
48