Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion install.php
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,9 @@ function show_help(): void {
// No arguments provided, check if we should parse from STDIN (for curl | php usage)
if (!stream_isatty(STDIN)) {
// We're being piped to, look for arguments after the separator
list($options, $option_count) = parseArguments();
list($parsed_options, $option_count) = parseArguments();
// Merge the parsed options with the defaults
$options = array_merge($options, $parsed_options);
}
}

Expand Down Expand Up @@ -1161,14 +1163,22 @@ function parseArguments() {
$option_count = 0;

// Look for -- separator in argv to handle piped arguments
// When piped through curl, argv[0] is "Standard input code" and arguments start at argv[1]
$start_index = 1;
$found_separator = false;
for ($i = 1; $i < $argc; $i++) {
if ($argv[$i] === '--') {
$start_index = $i + 1;
$found_separator = true;
break;
}
}

// If no separator found and we're being piped, assume all args after argv[0] are ours
if (!$found_separator && $argc > 1 && $argv[0] === 'Standard input code') {
$start_index = 1;
}
Comment on lines +1177 to +1180
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This conditional block appears to be redundant. The $start_index variable is initialized to 1 on line 1167. If the preceding for loop does not find a -- separator, $found_separator will be false and $start_index will still be 1. This if block then re-assigns $start_index to 1, which has no effect on the program's logic.

This block and its preceding comment can be safely removed to improve code clarity. If there was a different intention here that I'm missing, please clarify.


// Process arguments after the separator
for ($i = $start_index; $i < $argc; $i++) {
$arg = $argv[$i];
Expand Down