I have a problem with the shell function in makefiles. Doing this:
var := $(shell some-command)
Allows me to capture the stdout of some-command.
Doing this:
var := $(shell some-command 2>&1)
Allows me to capture the stdout and the stderr of some-command.
How do I capture the stderr of the shell itself?
This makefile ilustrates the problem:
var1 := $(shell date 2>&1)
var2 := $(shell ls aaa 2>&1)
var3 := $(shell a-command-which-does-not-exist 2>&1)
show-me:
@echo var1: \"$(var1)\"
@echo var2: \"$(var2)\"
@echo var3: \"$(var3)\"
It will produce:
/bin/sh: 1: a-command-which-does-not-exist: not found
var1: "So 6. Feb 00:37:05 CET 2022"
var2: "ls: cannot access aaa: No such file or directory"
var3: ""
I would like to capture /bin/sh: 1: a-command-which-does-not-exist: not found into var3. Is this possible?