[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #57625] Shell builtins not working unless explicitly set SHELL to "
Paul D. Smith
[bug #57625] Shell builtins not working unless explicitly set SHELL to "sh"
Sat, 18 Jan 2020 10:25:09 -0500 (EST)
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0
Update of bug #57625 (project make):
Status: None => Fixed
Assigned to: None => psmith
Open/Closed: Open => Closed
Fixed Release: None => SCM
Triage Status: None => Small Effort
Follow-up Comment #1:
There are a confluence of factors involved here.
First, make tries to avoid invoking a shell as a performance improvement. If
make determines that the command to be invoked is a simple command it uses a
"fast path" where it simply forks and execs the command directly and doesn't
use a shell to do it.
GNU make contains a list of special commands which are known to be shell
built-ins, etc.; if the command starts with those make knows it needs to
invoke a shell _even if_ the command appears to be simple enough to invoke
Unfortunately, "type" is missing from that list; I have fixed that, along with
adding a few other missing items, and the fix will be in the next release.
As for setting SHELL; the documentation actually doesn't say the default value
of SHELL is "sh", it says the default value is "/bin/sh". If you used "SHELL
= /bin/sh" instead of "SHELL = sh" then you wouldn't see the odd behavior (it
would work the same as if you hadn't set SHELL). The change you observe is
because make also tries to detect whether the SHELL you set is a POSIX shell
or not. If make isn't sure, it will never choose the fast path and always
invoke the shell. Make is very conservative about this and only checks a few
well-known paths to decide whether the shell is POSIX or not; "sh" doesn't
meet that criteria so by setting "SHELL = sh" you've disabled fast-path for
all your recipes.
As a workaround for your current environment you can easily convince make to
always invoke a shell for your command simply by using a special character.
One simple one is ";"; if make sees a semicolon in the command it will always
skip the fast path and invoke a shell:
Reply to this item at:
Message sent via Savannah