Last active
January 24, 2020 17:28
-
-
Save judgej/318b59b1e57867ffd2968dfa1521421a to your computer and use it in GitHub Desktop.
Revisions
-
judgej revised this gist
Mar 1, 2018 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -40,10 +40,10 @@ wrapper_func() { echo $PATH if [[ $PATH = *"$BASEDIR"* ]]; then PATH=$(echo $PATH | sed 's#'$BASEDIR'[0-9.]*[^/]/bin#'$BASEDIR$VERSION'/bin#') echo "Updated:" else echo "Added:" PATH="$BASEDIR$VERSION/bin:$PATH" fi echo $PATH else @@ -53,3 +53,4 @@ wrapper_func() { } wrapper_func $1 -
judgej revised this gist
Mar 1, 2018 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,6 +7,7 @@ # # It will look for the path to the current PHP version in your PATH and switch to # the new PHP version. # If you do not have a path to a php version, then it will add one. # If the version you specify does not exist, it will list the versions that are available. # I wrote this for a Plesk server with various applications running under different versions # of PHP, allowing me to quickly swicth between them on the command line. @@ -37,7 +38,13 @@ wrapper_func() { if $(list_include_item "$VERSIONS" "$VERSION") ; then echo $PATH if [[ $PATH = *"$BASEDIR"* ]]; then PATH=$(echo $PATH | sed 's#'$BASEDIR'[0-9.]*[^/]/bin#'$BASEDIR$VERSION'/bin#') echo "Updating:" else echo "Adding:" PATH="$PATH:$BASEDIR$VERSION/bin" fi echo $PATH else echo Usage: $(basename $0) php-version -
judgej created this gist
Aug 31, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ #!/bin/bash # Use the script like this: # . setphp 7.1 # or # source setphp 5.6 # # It will look for the path to the current PHP version in your PATH and switch to # the new PHP version. # If the version you specify does not exist, it will list the versions that are available. # I wrote this for a Plesk server with various applications running under different versions # of PHP, allowing me to quickly swicth between them on the command line. # https://stackoverflow.com/questions/8063228/how-do-i-check-if-a-variable-exists-in-a-list-in-bash # list_include_item "10 11 12" "2" function list_include_item { local list="$1" local item="$2" if [[ $list =~ (^|[[:space:]])"$item"($|[[:space:]]) ]] ; then # yes, list include item result=0 else result=1 fi return $result } wrapper_func() { # The location of the PHP versions supplied by Plesk. local BASEDIR="/opt/plesk/php/" # The requested PHP version. local VERSION=$1 # The available PHP versions. local VERSIONS=$(ls $BASEDIR) if $(list_include_item "$VERSIONS" "$VERSION") ; then echo $PATH PATH=$(echo $PATH | sed 's#'$BASEDIR'[0-9.]*[^/]/bin#'$BASEDIR$VERSION'/bin#') echo $PATH else echo Usage: $(basename $0) php-version echo Versions are: $VERSIONS fi } wrapper_func $1