bugmake - Bugs: bug #25190, define expansion seems to lose the...

 
 

bug #25190: define expansion seems to lose the final newline

Submitted by:  Norman Abramovitz <nabramovitz>
Submitted on:  Sun 28 Dec 2008 05:49:38 AM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: Not A BugPrivacy: Public
Assigned to: NoneOpen/Closed: Closed
Component Version: 3.81Operating System: Any
Fixed Release: NoneTriage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sun 28 Dec 2008 07:53:28 AM UTC, comment #2:

This is not a bug. See the GNU make manual, section "Defining Variables Verbatim", where it says:

The value in an ordinary assignment cannot contain a newline; but the newlines that separate the lines of the value in a `define' become part of the variable's value (except for the final newline which precedes the `endef' and is not considered part of the value).

Note the final parenthetical comment (highlight added).

Paul D. Smith <psmith>
Project Administrator
Sun 28 Dec 2008 06:32:23 AM UTC, comment #1:

The cut and past lost the expected indentation or tabs on lines. Adding an attachment (unix eol) with the test case code.

(file #17143)

Norman Abramovitz <nabramovitz>
Sun 28 Dec 2008 05:49:38 AM UTC, original submission:

Environment

Red Hat Enterprise Linux Server release 5.2 (Tikanga)This program built for i686-redhat-linux-gnu

If I do not have the empty line at the end of the pkgify_rule, the next generated program target assignment (yyy) gets combined with the previous generated chmod line (xxx). The blank line should not be required.

Execution results with the blank line.

$ gmake -f x -n all
echo xxx comes from xxx.sh
chmod +x xxx
echo yyy comes from yyy.sh
chmod 644 yyy
echo all done

Execution results without the blank line.

$ gmake -f x -n all
echo xxx comes from xxx.sh
chmod +x xxx yyy: PKGIFY_MODE?=+x
echo yyy comes from yyy.sh
chmod 644 yyy
echo all done

It is not a printing error since if I run without the -n flag I get the following errors. Since I made my sources phoney objects to simplify the test case, I expect two error messages from chmod not three.

$ gmake -f x all
echo xxx comes from xxx.sh
xxx comes from xxx.sh
chmod: cannot access `xxx': No such file or directory
chmod: cannot access `yyy:': No such file or directory
chmod: cannot access `PKGIFY_MODE?=+x': No such file or directory
gmake: *** [xxx] Error 1

The test script follows.

SH_PROGRAM=xxx yyy
SHSRC=xxx.sh yyy.sh
.PHONY: xxx.sh yyy.sh

yyy: PKGIFY_MODE=644

PKGIFY=echo $@ comes from $<

all: ${SH_PROGRAM}
echo all done

indices=$(shell (( i= 0 )); while (( i < $(words ${${1}}) )); do (( i += 1 )); l="$${l} $$i"; done; echo $${l})

define pkgify_rule
$(1): PKGIFY_MODE?=+x
${1}: ${2}
$${PKGIFY}
@chmod $${PKGIFY_MODE} $$@

endef
# if the blank line above the endef is removed the next target assignment becomes
# part of the previous chmod line

define pkgify_template
$(foreach idx,$(call indices,${1}), $(call pkgify_rule,$(word ${idx},${$(1)}),$(word ${idx},${${2}})))
endef

# this ifdef works 3.81 but not in 3.80. if function works 3.80 and 3.81
ifdef SH_PROGRAM
$(eval $(call pkgify_template,SH_PROGRAM,SHSRC))
endif

xyz: xyz.sh
echo xyz

Norman Abramovitz <nabramovitz>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #17143:  bug25190.ksh added by nabramovitz (795B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by psmith (Posted a comment)
  • -unavailable- added by nabramovitz (Submitted the item)
  • -unavailable- added by nabramovitz
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 28 Dec 2008 07:53:28 AM UTCpsmithStatusNone=>Not A Bug
      Open/ClosedOpen=>Closed
    Sun 28 Dec 2008 06:32:23 AM UTCnabramovitzAttached File-=>Added bug25190.ksh, #17143
    Sun 28 Dec 2008 05:49:38 AM UTCnabramovitzCarbon-Copy-=>Added nabramovitz

    Back to the top


    Powered by Savane 3.1-cleanup1