bug-make
[Top][All Lists]
Advanced

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

Re: backslash-newline change: my world has become black


From: Paul D. Smith
Subject: Re: backslash-newline change: my world has become black
Date: Tue, 20 Dec 2005 17:39:21 -0500

%% Dan Jacobson <address@hidden> writes:

  dj> You guys have a new backslash-newline deal that is breaking 1000
  dj> of my scripts.

  dj>   make
  dj>   perl -pwle '\
  dj>           BEGIN{print "#jidanni ~root/config auto changed"}\
  dj>           s/^server pool.ntp.org/#jidanni off $&/;\
  dj>           END{print "#more jidanni ~root/config auto changes";\
  dj>           print "server $_.stdtime.gov.tw offline maxdelay 1" for qw/tick 
\
  dj>           time tock/; print "mailonchange address@hidden 12";\
  dj>           print "#jidanni: restarting in /etc/ppp/ip-up.d/chrony so \
  dj>           can use hostnames\n#http://www.stdtime.gov.tw/ntp/CONF.HTM"}' 
\...
  dj>   Useless use of single ref constructor in void context at -e line 6.
  dj>   Useless use of reference constructor in void context at -e line 2.
  dj>   Useless use of reference constructor in void context at -e line 4.
  dj>   Can't call method "BEGIN" without a package or object reference at -e 
line 2, <> line 1.

  dj> There is no documentation on how I am supposed to fix my 1000 scripts.

The behavior of backslash/newline in a makefile command script follows
exactly the behavior you would get if you typed the same command
directly to shell prompt.  That's the POSIX-required behavior.  And, it
enables all sorts of other capabilities for multi-line scripting that
were not possible before.

There are two ways to do what you want to do:

First, you can use double quotes instead of single quotes.  Just as with
the shell prompt, inside double quotes the backslash-newline will be
processed and removed by the shell before your command is invoked.
Consider the difference between running:

    perl -e '\
            exit(0);'

and:

    perl -e "\
            exit(0);"


Of course, changing to double quotes has a lot of ramifications on your
script for that very reason (the shell parses the content of the quoted
string) and so this can be painful.

Another option is to store the script in a make variable:
backslash-newline management in make variables uses make rules, not
shell rules.  You didn't provide an actual example of a make target that
I can use for an example, but this will work the same way the old code
used to work:

    PERLFUNC = '\                                                           
           BEGIN{print "#jidanni ~root/config auto changed"}\              
           s/^server pool.ntp.org/#jidanni off $&/;\                       
           END{print "#more jidanni ~root/config auto changes";\           
           print "server $_.stdtime.gov.tw offline maxdelay 1" for qw/tick \
           time tock/; print "mailonchange address@hidden 12";\
           print "#jidanni: restarting in /etc/ppp/ip-up.d/chrony so \
           can use hostnames\n#http://www.stdtime.gov.tw/ntp/CONF.HTM"}'

    all:
            perl -e $(PERLFUNC)

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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