Home > Net >  Makefile - when running shell commands the output doesn't have line breaks
Makefile - when running shell commands the output doesn't have line breaks

Time:06-24

I'm editing a makefile that ran a lot of sh scripts, and i just added one that runs a terraform command. When i use directly the .SH file (or the command manually in console, the output is OK, but if i ran it inside the makefile, the output is all together, without spacing or line breaks.

Is there any way to fix this?

PFB commands and outputs.

runcommands.sh (it ran as ./runcommands.sh init/plan/etc)

terraform $1 

output:

Terraform initialized in an empty directory!

The directory has no Terraform configuration files. You may begin working with Terraform immediately by creating Terraform configuration files.

Makefile:

plan:
    $(shell ./runcommands.sh init) 

output:

Terraform initialized in an empty directory! The directory has no Terraform configuration files. You may begin working with Terraform immediately by creating Terraform configuration files.

CodePudding user response:

The recipe:

plan:
    $(shell ./runcommands.sh init)

does not do what you seem to think it does. The $(shell ...) syntax executes the command and builds a string. Because of its location in the Makefile, that string is then executed as a command. You almost certainly do not want the output of ./runcommands.sh to be executed. You want:

plan:
    ./runcommands.sh init 
  • Related