如何处理在GNU shell扩展在Ubuntu下做什么呢? [英] How to handle shell expansions in GNU Make under Ubuntu?
问题描述
由于这个非常简单的的Makefile
:
all:
@mkdir -pv test/{a,b}
我得到这个操作系统输出x 10.6.8和CentOS 5.5:
I get this output on OS X 10.6.8 and CentOS 5.5:
mkdir: created directory `test'
mkdir: created directory `test/a'
mkdir: created directory `test/b'
但在Ubuntu 11.04我得到这样的:
But on Ubuntu 11.04 I get this:
mkdir: created directory `test'
mkdir: created directory `test/{a,b}'
运行命令的mkdir -pv测试/ {A,B}
在所有平台上的外壳给人手动预期的结果。
Running the command mkdir -pv test/{a,b}
manually in the shell on all platforms gives the expected result.
GNU的版本做是在所有平台上是相同的:
The version of GNU Make is the same on all platforms:
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program is built for [PLATFORM]
什么在Ubuntu下是不同的,为什么不shell扩展工作呢?
What's different under Ubuntu and why doesn't the shell expansion work there?
推荐答案
这个问题可能是,使鱼卵 / bin / sh的
。它通常是一个符号链接到你的系统默认的shell。
The problem is probably that Make spawns /bin/sh
. It is usually a symlink to your system's default shell.
您可以确保它指向bash的(因为这是一个bashism)。也许,现在是/斌/破折号或/ bin / sh的,这取决于你的Ubuntu版本。
You could make sure it points to bash (as this is a bashism). Probably, it is now /bin/dash or /bin/sh, depending on your version of Ubuntu.
更容易的选择:
SHELL=/bin/bash
all:
@echo a{3,4}
@bash -c 'echo a{3,4}'
本打印相同的输出两次,除非你注释掉的 SHELL =
行
This prints the same output twice unless you comment-out the SHELL=
line
如果你不能/不想修改make文件,您可以调用它像这样:
If you can't/don't want to modify the make file, you can invoke it like so:
make SHELL=/bin/bash
提防与子makefile文件或包含的相互作用。你可能想看看让-e
选项和化妆导出
关键字:<一href=\"http://www.gnu.org/s/hello/manual/make/Variables_002fRecursion.html\">http://www.gnu.org/s/hello/manual/make/Variables_002fRecursion.html
这篇关于如何处理在GNU shell扩展在Ubuntu下做什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!