相关疑难解决方法(0)

目的是什么:(冒号)GNU Bash内置?

命令的目的是什么,什么都不做,只是一个评论领导者,但实际上是一个内置的shell?

它比在每个调用中将注释插入脚本大约40%要慢,这可能会根据注释的大小而有很大差异.我能看到的唯一可能的原因是:

# poor man's delay function
for ((x=0;x<100000;++x)) ; do : ; done

# inserting comments into string of commands
command ; command ; : we need a comment in here for some reason ; command

# an alias for `true' (lazy programming)
while : ; do command ; done
Run Code Online (Sandbox Code Playgroud)

我想我真正想要的是它可能具有的历史应用.

bash shell built-in

313
推荐指数
11
解决办法
11万
查看次数

Makefile变量作为先决条件

在Makefile中,deploy配方需要设置一个环境变量ENV来正确执行自身,而其他人则不关心,例如:

ENV = 

.PHONY: deploy hello

deploy:
    rsync . $(ENV).example.com:/var/www/myapp/

hello:
    echo "I don't care about ENV, just saying hello!"
Run Code Online (Sandbox Code Playgroud)

如何确保设置此变量,例如:是否有办法将此makefile变量声明为部署配方的先决条件,例如:

deploy: make-sure-ENV-variable-is-set
Run Code Online (Sandbox Code Playgroud)

谢谢.

makefile

127
推荐指数
8
解决办法
7万
查看次数

为什么.PHONY隐式模式规则没有被触发?

我有以下递归makefile:

.PHONY: all clean

%.subdir:
    $(MAKE) -C src $*
    $(MAKE) -C dict $*

all: all.subdir

clean: clean.subdir
Run Code Online (Sandbox Code Playgroud)

它工作正常:

$ make all
make -C src all
make[1]: Entering directory `/or-1.3.6-fix/src'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/or-1.3.6-fix/src'
make -C dict all
make[1]: Entering directory `/or-1.3.6-fix/dict'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/or-1.3.6-fix/dict'
Run Code Online (Sandbox Code Playgroud)

但将%.subdir规则定义为虚假更合乎逻辑:

.PHONY: all clean all.subdir clean.subdir
Run Code Online (Sandbox Code Playgroud)

现在让我停止工作:

$ make all
make: Nothing to be done for `all'.
$ make …
Run Code Online (Sandbox Code Playgroud)

makefile

22
推荐指数
3
解决办法
1万
查看次数

检查变量是否在makefile中定义

我有一个GNU Makefile(版本3.81),如下所示:

.PHONY: SPOneDot

SPOneDot:
    ifndef X
    X=0.05
    $$(info X undefined, changed to $X)
    endif
    ifndef Y
    Y=0.05
    $$(info Y undefined, changed to $Y)
    endif
    python ./Submit3DSP.py -f OneDot.qdt -x $(X) -y $(Y)
Run Code Online (Sandbox Code Playgroud)

我使用以下命令行执行:make X=0.1 Y=0.1 SPOneDot但是我得到以下结果:

ifndef X
make: ifndef: Command not found
make: *** [SPOneDot] Error 127
Run Code Online (Sandbox Code Playgroud)

我查看了makefile文档,看到其他人使用它.任何帮助表示赞赏,这可能是愚蠢的.

conditional makefile environment-variables gnu-make

17
推荐指数
2
解决办法
3万
查看次数

Makefile -- 如果未设置变量则出错

如果未设置变量,则遵循Abort makefile 中的建议我尝试使用ifndef但它不起作用。

生成文件:

foo:
        ifndef BAR
        $(error "Must set BAR")
        endif
Run Code Online (Sandbox Code Playgroud)

make foo BAR=quux不起作用:

Makfile:2: *** "Must set BAR". Stop.
Run Code Online (Sandbox Code Playgroud)

是什么赋予了?是空格问题吗?还是我完全误解了?

(我正在使用 GNU Make)

我也试过:

foo:
ifndef BAR
$(error "Must set BAR")
endif
        echo $(BAR)
Run Code Online (Sandbox Code Playgroud)

这似乎是一种工作,但ifndef如果调用 Makefile 中更下方的目标(不需要设置变量),仍然会导致调用。

makefile

2
推荐指数
1
解决办法
1493
查看次数