[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #57625] Shell builtins not working unless explicitly set SHELL to "
From: |
Paul D. Smith |
Subject: |
[bug #57625] Shell builtins not working unless explicitly set SHELL to "sh" |
Date: |
Sat, 18 Jan 2020 10:25:09 -0500 (EST) |
User-agent: |
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
directly.
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:
.POSIX:
run:
type make;
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?57625>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/