Skip to content
Open
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
17 changes: 16 additions & 1 deletion bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,22 @@ install_php() {
echo "Determining configuration options..."
local source_path=$(get_download_file_path $install_type $version $tmp_download_dir)
local configure_options="$(construct_configure_options $install_path)"
local make_flags="-j$ASDF_CONCURRENCY"

# Use a local variable for concurrency calculation
local_concurrency="${ASDF_CONCURRENCY}"
# If ASDF_CONCURRENCY is "auto" or not set, determine the number of CPU cores
if [[ "${local_concurrency:-auto}" == "auto" || -z "${local_concurrency}" ]]; then
if command -v nproc >/dev/null 2>&1; then
local_concurrency=$(nproc)
elif [[ "$(uname)" == "Darwin" ]]; then
local_concurrency=$(sysctl -n hw.ncpu)
else
local_concurrency=1 # Fallback if detection fails
fi
fi

# Now use the local_concurrency for make
make_flags="-j${local_concurrency}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Variable Scope Issue Causes Namespace Pollution

The local_concurrency and make_flags variables are not declared with the local keyword. This makes them global, which pollutes the namespace and could lead to unexpected behavior, especially on repeated function calls. The original make_flags was local, and local_concurrency was also intended to be local.

Fix in Cursor Fix in Web

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Global Variable Assignment Error

The make_flags variable is assigned without the local keyword, making it global instead of function-local. This deviates from the script's established scoping pattern and encapsulation.

Fix in Cursor Fix in Web


local operating_system=$(uname -a)

Expand Down