Skip to content

Commit 11242c0

Browse files
author
Greg Bowler
committed
Check version exists
1 parent 89af009 commit 11242c0

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

switch-php-version

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
#!/bin/bash
2+
set -e
3+
24
if [ "$1" = "latest" ]
35
then
46
version=7.4
57
else
6-
version=$1
8+
version="$1"
79
fi
810

9-
rm -f /usr/bin/php
10-
ln -s "/etc/php/$version/bin/php" "/usr/bin/php"
11+
php_bin="/etc/php/$version/bin/php"
12+
13+
if test -f $php_bin
14+
then
15+
rm -f /usr/bin/php
16+
ln -s "$php_bin" "/usr/bin/php"
17+
echo "Successfully linked $php_bin"
18+
else
19+
echo "Error linking $php_bin: version doesn't exist"
20+
exit 1
21+
fi

0 commit comments

Comments
 (0)