help-make
[Top][All Lists]
Advanced

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

RE: use of hyphen in recipes to ignore errors precludes using -- as comm


From: Kaz Kylheku (gmake)
Subject: RE: use of hyphen in recipes to ignore errors precludes using -- as comment character
Date: Sun, 21 Feb 2021 23:08:34 -0800
User-agent: Roundcube Webmail/0.9.2

On 2021-02-21 22:52, Cook, Malcolm wrote:
On 2021-02-19 21:12, Cook, Malcolm wrote:
Gnu manual reads:

To ignore errors in a recipe line, write a '-' at the beginning of
the line's text (after the initial tab)...

I think it would be good if the implementation changed to allow instead

To ignore errors in a recipe line, write a '-' as the first character
of the line's text (immediately after the initial tab with no other
preceding whitespace)...

I don't see the difference. There isn't any whitespace allowed between
the
tab and the minus.

Why do you say this? According to what?

Simply, none of the documentation (POSIX, GNU Make manual) says
anything about any optional space before the - character, and
empirical testing shows no such whitespace is tolerated.


In any case, this is a POSIX feature:

Makefile command lines can have one or more of the following
prefixes: a <hyphen-minus> ( '-' ), an at-sign ( '@' ), or a
<plus-sign> ( '+' ). These shall modify the way in which make
processes the command.

- If the command prefix contains a <hyphen-minus>, or the -i
option is present, or the special target .IGNORE has either
the current target as a prerequisite or has no prerequisites,
any error found while executing the command shall be ignored.

@ If the command prefix contains an at-sign and the make
utility command line -n option is not specified, or the -s
option is present, or the special target .SILENT has either
the current target as a prerequisite or has no prerequisites,
the command shall not be written to standard output before it
is executed.

+ If the command prefix contains a <plus-sign>, this
indicates a makefile command line that shall be executed even
if -n, -q, or -t is specified.


I guess what is not clearly defined at least to me is what constitutes
a "prefix".

I says "Makefile command lines can have one or more of these
prefixes: ...". Therefore, a prefix must be a mixture of those three
characters, and only those characters, immediately following
the tab.

Apparently whitespace gets ignored in looking for a prefix.  To me
this is unfortunate and what I am suggesting might be changed.

But it's not ignored; whitespace is simply not allowed in a prefix;
if whitespace is seen while scanning the prefix, the (possibly empty)
prefix has thereby ended. That space is the start of the line after
the prefix.

How are you embedding here strings into make recipes? That generally
doesn't work very well, unless perhaps you are using the GNU Make
extension which allows all of he lines of a recipe to be a single
shell script, rather than individual scripts.

That is what I am doing, yes.

.ONESHELL

To me all this stuff about prefixes in the middle of a multiline
recipe doesn't even make sense with .ONESHELL.

But there is no such thing, according to the documentation:

     If '.ONESHELL' is provided, then only the first line of the recipe
  will be checked for the special prefix characters ('@', '-', and '+').
Subsequent lines will include the special characters in the recipe line when the 'SHELL' is invoked. If you want your recipe to start with one
  of these special characters you'll need to arrange for them to not be
  the first characters on the first line, perhaps by adding a comment or
similar. For example, this would be a syntax error in Perl because the
  first '@' is removed by make:

     .ONESHELL:
     SHELL = /usr/bin/perl
     .SHELLFLAGS = -e
     show :
             @f = qw(a b c);
             print "@f\n";

Cheers ...



reply via email to

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