jubianchi / phpswitch

A CLI utility to help you build and test PHP versions
http://jubianchi.github.io/phpswitch/
MIT License
90 stars 8 forks source link

I have some little bug #14

Closed lyrixx closed 11 years ago

lyrixx commented 11 years ago

Hello. Thanks for your latest patch ;)

So, I have installed phpswitch. IMHO a trace is better than a big text, so:

>root@greg-laptop[/opt/phpswitch](master %) ./bin/phpswitch init
Directory /opt/phpswitch/.phpswitch already exists
Directory /opt/phpswitch/.phpswitch/downloads already exists
Directory /opt/phpswitch/.phpswitch/sources already exists
Directory /opt/phpswitch/.phpswitch/installed already exists
Directory /opt/phpswitch/.phpswitch/doc already exists
You should source /opt/phpswitch/.phpswitch/.phpswitchrc to use phpswitch
>root@greg-laptop[/opt/phpswitch](master %) . /opt/phpswitch/.phpswitch/.phpswitchrc
PHP version phpswitch-5.3.21 is not installed. Do you want to install it ? no

  [InvalidArgumentException]                 
  Version phpswitch-5.3.21 is not installed  

php:switch [-l|--local] [-g|--global] [-a|--apache2] version
php switch [-l|--local] [-g|--global] [-a|--apache2] version

>root@greg-laptop[/opt/phpswitch](master %) ls
behat.yml  bin  composer.json  composer.lock  composer.phar  doc  LICENSE  README.md  src  tests  Vagrantfile  vendor
PHP version phpswitch-5.3.21 is not installed. Do you want to install it ? no

  [InvalidArgumentException]                 
  Version phpswitch-5.3.21 is not installed  

php:switch [-l|--local] [-g|--global] [-a|--apache2] version
php switch [-l|--local] [-g|--global] [-a|--apache2] version

After sourcing /opt/phpswitch/.phpswitch/.phpswitchrc phpswitch ask me, for every command, if I want to install php 5.3.21.

Note:

More over I have a second bug. When I run the following commands, after sourcing the ...rc:

>root@greg-laptop[/opt/phpswitch] cd /
>root@greg-laptop[/opt/phpswitch] pwd
/

my PS1 is broken.

jubianchi commented 11 years ago

As a workaround, you can do something like that to make phpswitch stop asking you to install a specific php version:

$ export PROMPT_COMMAND=$(echo $PROMPT_COMMAND | sed 's/phpswitch_dir *//')

This is a feature of phpswitch : whenever you enter a directory containing a .phpswitch.ymlfile, phpswitch will search for an installed php that matches the one described in this file. If it can find any php, phpswitch will ask you if you want to install it.

I agree that ATM, phpswitch is a bit boring, asking for this before each prompt. I'll improve this so phpswitch will remember the user's answer in cases he refuses to install the php version.

About you PS1 being broken, I have to find what's happening. I'm using ZSH and there is no problem with it.

Thanks for the report :wink:

jubianchi commented 11 years ago

I tried to reproduce the bug breaking your prompt but unfortunatelly I did not get it:

phpswitch_issue_14