bug-make
[Top][All Lists]
Advanced

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

Re: semicolon effects


From: Paul Smith
Subject: Re: semicolon effects
Date: Mon, 26 Apr 2021 13:52:15 -0400
User-agent: Evolution 3.36.4-0ubuntu1

On Mon, 2021-04-26 at 06:25 +0800, Dan Jacobson wrote:
> $ make B
> :;      Z
> 
> /bin/sh: line 1: Z: command not found
> make: *** [Makefile:2: B] Error 127
> 
> $ make C
> :
> Z
> 
> make: Z: No such file or directory
> make: *** [Makefile:5: C] Error 127
> 
> So we see that "the effect is the same" is inaccurate.

This has nothing to do with using a semicolon to put the command on the
same line as the target.  You'd get the same effect if you DIDN'T use a
semicolon and put the same command on the line after the target:

  B:
        :; Z
  C:
        :
        Z

The issue is that in the first example the script is "complex" so make
uses its slow path solution, which is to run /bin/sh -c ":; Z".  Thus
you get an error from the shell.

In the second example, the "Z" command is by itself so it's "simple" so
make uses its fast path solution, which is to fork and exec "Z"
directly without a shell.  Thus you get an error from make.




reply via email to

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