@@ -12,7 +12,9 @@ PHPVM_VERSION="1.7.0"
1212PHPVM_TEST_MODE=" ${PHPVM_TEST_MODE:- false} "
1313
1414# Fix to prevent shell crash when sourced
15- (return 0 2> /dev/null) && return 0 || true # Allow sourcing without execution
15+ if (return 0 2> /dev/null); then
16+ return 0
17+ fi
1618
1719PHPVM_DIR=" ${PHPVM_DIR:- $HOME / .phpvm} "
1820PHPVM_VERSIONS_DIR=" $PHPVM_DIR /versions"
@@ -1961,8 +1963,8 @@ EOF
19611963 mkdir -p " $HOME /project"
19621964 echo " 7.4" > " $HOME /project/.phpvmrc"
19631965
1964- # Change to the project directory
1965- cd " $HOME /project"
1966+ # Change to the project directory
1967+ cd " $HOME /project" || return 1
19661968
19671969 # Test auto-switching
19681970 auto_switch_php_version > /dev/null
@@ -1984,8 +1986,8 @@ EOF
19841986 mkdir -p " $HOME /alias_project"
19851987 echo " default" > " $HOME /alias_project/.phpvmrc"
19861988
1987- # Change to the project directory
1988- cd " $HOME /alias_project"
1989+ # Change to the project directory
1990+ cd " $HOME /alias_project" || return 1
19891991
19901992 # Test auto-switching
19911993 auto_switch_php_version > /dev/null
@@ -2001,8 +2003,8 @@ EOF
20012003 mkdir -p " $HOME /bad_project"
20022004 touch " $HOME /bad_project/.phpvmrc"
20032005
2004- # Change to the project directory
2005- cd " $HOME /bad_project"
2006+ # Change to the project directory
2007+ cd " $HOME /bad_project" || return 1
20062008
20072009 # Test auto-switching with empty .phpvmrc
20082010 output=$( auto_switch_php_version 2>&1 )
@@ -2666,7 +2668,8 @@ else
26662668
26672669 # Auto-use .phpvmrc if enabled and present
26682670 if [ " ${PHPVM_AUTO_USE:- true} " = " true" ] && [ -f " .phpvmrc" ]; then
2669- command -v auto_switch_php_version > /dev/null 2>&1 &&
2671+ if command -v auto_switch_php_version > /dev/null 2>&1 ; then
26702672 auto_switch_php_version 2> /dev/null || true
2673+ fi
26712674 fi
26722675fi
0 commit comments