make-alpha
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: .ONESHELL enhancement?


From: David Boyce
Subject: Re: .ONESHELL enhancement?
Date: Tue, 22 Sep 2009 18:43:04 -0400

On Tue, Sep 22, 2009 at 3:34 PM, Paul Smith <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]