Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
604 views
in Technique[技术] by (71.8m points)

networking - GNU-Make: Remote command with ssh as the shell?

Suppose I want to try the following:

SHELL:=ssh virtual-machine
# or: SHELL:=ssh virtual-machine bash
.PHONY:
foo:
  echo "foo"

# on the command line
make foo

# returns
Unknown cipher type 'echo "foo"'

Revealing that, more or less, "it worked!", but that make is executing the following:

ssh virtual-machine -c "echo "foo""

Understanding that this is an XY question involving make and ssh, my solution-neutral question is:

How does one generate this remote subshell behavior properly using make?

And, understanding this may be a bad idea or there may be a better way, my specific question is:

Is there a way to customize the way make executes the SHELL variable?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Quoting GNU make's manual, section 5.3.2 (Choosing the Shell):

The program used as the shell is taken from the variable SHELL. If this variable is not set in your makefile, the program /bin/sh is used as the shell. The argument(s) passed to the shell are taken from the variable .SHELLFLAGS. The default value of .SHELLFLAGS is -c normally, or -ec in POSIX-conforming mode.

Hence setting .SHELLFLAGS to an empty value should do what you want


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...