我安装了多个版本的 PHP,对于我的正常开发,我总是使用通过自制软件安装的 PHP 5.5.x。
在 fish shell 里
which php & php --version
=> /usr/local/bin/php
=> PHP 5.5.8 (cli) (built: Jan 16 2014 15:58:25)
路径正确。
我的问题是,当我必须使用 Drupal 进行开发时,我使用 MAMP 作为捆绑灯组,并且 MAMP 包含自己的 php 版本。我的问题是,在将 Drush 与 Drupal 结合使用时,我无法像通常在 bash 中那样设置 PHP 可执行文件路径。我只希望 drush 使用捆绑的 PHP 版本/可执行文件。
在 bash 中我可以这样做:
# Set Drush root to MAMP PHP
export DRUSH_PHP=/Applications/MAMP/bin/php/php5.5.3/bin/php
但这在 fish shell 中不起作用,我试过这个(没有成功):
fish 配置位置:~/.config/fish/config.fish
set -x DRUSH_PHP=/Applications/MAMP/bin/php/php5.5.3/bin/php
如果我以 drush status
运行 fishshell,我总是得到这个:
Drupal version : 7.26
Site URI : http://default
Database driver : mysql
Database username : root
Database name : dev-db
Default theme : garland
Administration theme : garland
PHP executable : /usr/local/bin/php
PHP configuration : /usr/local/etc/php/5.5/php.ini
PHP OS : Darwin
Drush version : 6.2.0
Drush configuration :
Drush alias files :
Drupal root : /Applications/MAMP/htdocs/Sandbox/dev
Site path : sites/default
File directory path : sites/default/files
当我在 bourne shell 中运行相同的命令时,我得到了正确的设置:
Drupal version : 7.26
Site URI : http://default
Database driver : mysql
Database username : root
Database name : dev-db
Database : Connected
Drupal bootstrap : Successful
Drupal user : Anonymous
Default theme : bartik
Administration theme : seven
PHP executable : /Applications/MAMP/bin/php/php5.5.3/bin/php
PHP configuration : /Applications/MAMP/bin/php/php5.5.3/conf/php.ini
PHP OS : Darwin
Drush version : 6.2.0
Drush configuration :
Drush alias files :
Drupal root : /Applications/MAMP/htdocs/Sandbox/dev
Site path : sites/default
File directory path : sites/default/files
Temporary file directory path : /Applications/MAMP/tmp/php
那么,如何设置fish中DRUSH_PHP的导出路径呢?
最佳答案
如果您想在 fish shell 中模拟 export
命令,只需创建以下文件:
~/.config/fish/functions/export.fish
function export
if [ $argv ]
set var (echo $argv | cut -f1 -d=)
set val (echo $argv | cut -f2 -d=)
set -g -x $var $val
else
echo 'export var=value'
end
end
启动一个新的终端,然后按预期从你的 fish shell 运行 export
:
> export foo=123
> echo $foo
123
关于bash - 在 Fish Shell 中设置导出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21624512/