Re: .ONESHELL enhancement?
David Boyce <[email protected]>
| Newsgroups | gmane.comp.gnu.make.devel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Sep 22, 2009 at 3:34 PM, Paul Smith <[email protected]> wrote: > I can't speak to the Windows implementation, but why do you need to do > any translation of the script on POSIX systems? You can pass a string > containing a newline to the shell and it will work; you don't have to > add in "&&" or ";" or anything. > > E.g., for a command like: > > all: > echo hi > echo there > > why can't you just take this string as-is and invoke: > > /bin/sh -c "echo hi > echo there" > > ?? Because the semantics are different. Newline behaves more like ; than &&, and for .ONESHELL too work we need && semantics. Consider the following test case: ///////////////////////////////////////////////////////////////////// #include <stdlib.h> #include <unistd.h> int main(void) { (void)system("false && echo test 1"); (void)system("false ; echo test 2"); (void)system("false \n echo test 3"); return 0; } ///////////////////////////////////////////////////////////////////// When I run this the output is test 2 test 3 -DSB