Created
July 11, 2021 13:45
-
-
Save sukrosono/b2b891b0a32aac554c8632ae594d079b to your computer and use it in GitHub Desktop.
php swicher credit to https://bbs.archlinux.org/viewtopic.php?id=263999
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 characters
#!/bin/sh | |
[ "$#" -lt "1" ] && { | |
echo "Configure current shell to use a specific major PHP version. | |
Usage: usephp 7" | |
exit 0 | |
} | |
binary="php${1}" | |
wanted="/usr/bin/${binary}" | |
[ ! -f "${wanted}" ] && { | |
echo "'${binary}' not found. Using 'php'." | |
wanted="/usr/bin/php" | |
} | |
ln -sf "${wanted}" "${HOME}/bin/php" | |
inUse=$(php -nr "echo phpversion();") | |
echo "Shell configured to use PHP ${inUse}." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment