From 2bf7ab0207a039eed2acfff7fa4eadcc96f36686 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 16 Dec 2019 19:24:49 +0530 Subject: [PATCH] Fix add_extension on linux and macOS --- src/scripts/darwin.sh | 8 ++++---- src/scripts/linux.sh | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index f702ad5b..c918c8cb 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -37,11 +37,11 @@ add_extension() { extension=$1 install_command=$2 prefix=$3 - if ! php -m | grep -i -q "$extension" && [ -e "$ext_dir/$extension.so" ]; then + if ! php -m | grep -i -q ^"$extension"$ && [ -e "$ext_dir/$extension.so" ]; then echo "$prefix=$extension" >>"$ini_file" && add_log $tick "$extension" "Enabled" - elif php -m | grep -i -q "$extension"; then + elif php -m | grep -i -q ^"$extension"$; then add_log "$tick" "$extension" "Enabled" - elif ! php -m | grep -i -q "$extension"; then + elif ! php -m | grep -i -q ^"$extension"$; then exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null) if [ "$exists" = "200" ]; then ( @@ -49,7 +49,7 @@ add_extension() { add_log "$tick" "$extension" "Installed and enabled" ) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver" else - if ! php -m | grep -i -q "$extension"; then + if ! php -m | grep -i -q ^"$extension"$; then add_log "$cross" "$extension" "Could not find $extension for PHP $semver on PECL" fi fi diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index 6e92b339..499a2958 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -96,11 +96,11 @@ add_extension() extension=$1 install_command=$2 prefix=$3 - if ! php -m | grep -i -q "$extension" && [ -e "$ext_dir/$extension.so" ]; then + if ! php -m | grep -i -q ^"$extension"$ && [ -e "$ext_dir/$extension.so" ]; then echo "$prefix=$extension" >> "$ini_file" && add_log "$tick" "$extension" "Enabled" - elif php -m | grep -i -q "$extension"; then + elif php -m | grep -i -q ^"$extension"$; then add_log "$tick" "$extension" "Enabled" - elif ! php -m | grep -i -q "$extension"; then + elif ! php -m | grep -i -q ^"$extension"$; then ( eval "$install_command" && \ add_log "$tick" "$extension" "Installed and enabled"