0

I am using this Amazon Linux 2 AMI on an EC2 instance: amazon/amzn2-ami-hvm-2.0.20210525.0-x86_64-gp2

This Makefile works fine:

.SHELLFLAGS := -euo pipefail -c   
SHELL := bash

all:
    echo here

When I run make all I get:

bash-4.2$ make all
echo here
here

Then I add .ONESHELL: to the Makefile:

.ONESHELL:

.SHELLFLAGS := -euo pipefail -c   
SHELL := bash

all:
    echo here

Now when I run make all I get:

bash-4.2$ make all
echo here
bash: line 0: bash: echo here: invalid option name
make: *** [all] Error 2

Bash version:

GNU bash, version 4.2.46(2)-release (x86_64-koji-linux-gnu)

Make version:

GNU Make 3.82
Built for x86_64-koji-linux-gnu

If I remove the .SHELLFLAGS it will run successfully so it seems like a combination of the two is the problem. It also appears that with ONESHELL, the SHELLFLAGS are getting corrupted.

kldavis4
  • 2,177
  • 1
  • 22
  • 33
  • Don't know; that version of GNU make is quite old. It works OK for me with the current version of GNU make. Maybe try something newer? – MadScientist Jun 18 '21 at 19:06

1 Answers1

1

It's a bug in make 3.82, fixed in 4.0. When both .ONESHELL and .SHELLFLAGS is used, the flags are not tokenized correctly.

You need to either drop one of the two or upgrade your make (possibly outside your distribution).

raspy
  • 3,995
  • 1
  • 14
  • 18