dongtong0796 2013-04-26 09:39
浏览 66
已采纳

PHP生成目标的Makefile bash自动完成问题

In a large Makefile managed project, I recently added some PHP generated targets and bash completion stopped working: pressing [tab] does not trigger completion, but inserts a tab character.

I isolated the issue to this minimal Makefile:

# TARGETS = $(echo target1 target2)
TARGETS = $(php -r 'echo "target1 target2";')
# TARGETS = $(python -c 'print "target1 target2"')
# TARGETS = $(ruby -e 'puts "target1 target2"')

$(TARGETS):
    echo $@

If I use the bash-echo, python or ruby version of the TARGETS macro, bash completion works as expected, but if I use the php version bash completion becomes useless.

I can reproduce this issue on:

  • Mac OS 10.7.5 with default /usr/bin/php (5.3.15), default /bin/bash (3.2.48(1)-release), bash_completion 1.3_4 (installed with macports)
  • Ubuntu 10.04 with default /usr/bin/php (5.3.5-1ubuntu4ppa1), default /bin/bash (4.1.5(1)-release), default bash-completion 1:1.1-3ubuntu2

does anybody knows what is going wrong and what can be done about it?

  • 写回答

1条回答 默认 最新

  • dongtang4954 2013-04-26 14:07
    关注

    Ok, did some more researching and googling and found an explanation an workaround at:

    Apparently the readline support in PHP (PHP CLI with libedit compiled in for readline support on Ubuntu Lucid) causes the issue in some way (not analyzed by Paul Serby) and the workaround is to explicitly take control of the standard input of the PHP process.

    For example:

    TARGETS = $(php -r 'echo "target1 target2";' < /dev/null )
    

    or

    TARGETS = $(echo '' | php -r 'echo "target1 target2";' )
    

    both solutions work on both platforms I tried.

    Further references:

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 虚心请教几个问题,小生先有礼了
  • ¥30 截图中的mathematics程序转换成matlab