Skip to content

Commit f052ad7

Browse files
authored
Merge pull request #11 from ivangrynenko/feature/agents-md
fix: resolve hanging issue when piping installer through curl
2 parents a894363 + fdb77c4 commit f052ad7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

install.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,9 @@ function show_help(): void {
11111111
// No arguments provided, check if we should parse from STDIN (for curl | php usage)
11121112
if (!stream_isatty(STDIN)) {
11131113
// We're being piped to, look for arguments after the separator
1114-
list($options, $option_count) = parseArguments();
1114+
list($parsed_options, $option_count) = parseArguments();
1115+
// Merge the parsed options with the defaults
1116+
$options = array_merge($options, $parsed_options);
11151117
}
11161118
}
11171119

@@ -1161,14 +1163,22 @@ function parseArguments() {
11611163
$option_count = 0;
11621164

11631165
// Look for -- separator in argv to handle piped arguments
1166+
// When piped through curl, argv[0] is "Standard input code" and arguments start at argv[1]
11641167
$start_index = 1;
1168+
$found_separator = false;
11651169
for ($i = 1; $i < $argc; $i++) {
11661170
if ($argv[$i] === '--') {
11671171
$start_index = $i + 1;
1172+
$found_separator = true;
11681173
break;
11691174
}
11701175
}
11711176

1177+
// If no separator found and we're being piped, assume all args after argv[0] are ours
1178+
if (!$found_separator && $argc > 1 && $argv[0] === 'Standard input code') {
1179+
$start_index = 1;
1180+
}
1181+
11721182
// Process arguments after the separator
11731183
for ($i = $start_index; $i < $argc; $i++) {
11741184
$arg = $argv[$i];

0 commit comments

Comments
 (0)