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: Sat, 20 Feb 2021 15:50:33 -0800
User-agent: Roundcube Webmail/0.9.2

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.

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.


Experimenting with GNU Make, this succeeds for me, as expected,
with a diagnostic about the error being ignored:

.PHONY: all

all:
        -false
        echo foo

This, with an added space, fails:

.PHONY: all

all:
        - false
        echo foo


This would allow the use of '--' following an initial space after the
tab to serve its usual role introducing an SQL comment, allowing
commenting out selected lines of  SQL statement within a HERE string.

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.




reply via email to

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