Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Makefile – when running shell commands the output doesn't have line breaks

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

>Solution :

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 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading