bugmake - Bugs: bug #28092, $(shell false) should break build

 
 

bug #28092: $(shell false) should break build

Submitted by:  Stepan Koltsov <yozh>
Submitted on:  Wed 25 Nov 2009 06:06:02 PM UTC  
 
Severity: 3 - NormalItem Group: Enhancement
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open
Component Version: 3.81Operating System: None
Fixed Release: NoneTriage Status: None

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

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

 

(Jump to the original submission Jump to the original submission)

Thu 26 Nov 2009 06:37:52 PM UTC, comment #6:

Timothy, you've proven that you can work around make limitations.

Stepan Koltsov <yozh>
Thu 26 Nov 2009 06:28:25 PM UTC, comment #5:

Hi,

Ok, Mk2 then:

a:=$(shell echo "don't mess up this output"; echo " $$?")

code:=$(lastword $(a))
output:=$(strip $(patsubst %$(code),%,$(a)))
$(info exit code='$(code)')
$(info output='$(output)')

[tnmurphy@4GBL06592 ~]$ make -f t4.mk
exit code='0'
output='don't mess up this output'
make: *** No targets. Stop.

I think that the $(strip) is a bit of a cheat but it's pretty close to what should be done. This could probably be done completely properly with another patsubst.

Timothy N Murphy <tnmurphy>
Thu 26 Nov 2009 03:27:05 PM UTC, comment #4:

Timothy, echo $$? mixes up command output and exit code in single variable, it is not acceptable.

Stepan Koltsov <yozh>
Thu 26 Nov 2009 10:50:14 AM UTC, comment #3:

To get the exit code:

a:=$(shell cat fred.txt; echo $$?)
$(info exit=$(a))

make -f t.mk
cat: fred.txt: No such file or directory
exit=1

Timothy N Murphy <tnmurphy>
Wed 25 Nov 2009 07:28:33 PM UTC, comment #2:

Alternative requests then:

1. Add -e modifier to $(shell)

$(shell -e cat version.txt)

could break build. It mimics -e switch of /bin/sh. This shouldn't be a problem since there is no "-e" command.

2. Add another "shelle" command:

$(shelle cat version.txt)

Stepan Koltsov <yozh>
Wed 25 Nov 2009 06:38:28 PM UTC, comment #1:

There's no way $(shell ...) failing can or should cause make to stop. There are many legitimate reasons why the shell exiting with an error should not cause make to fail, and adding this would be an enormous backward-compatibility break.

For your situation, you can just check to see whether the result of the variable was valid; this will also catch the situation where there's an empty file as well as a non-existent one:

I agree it might be useful to find out the exit code of the last $(shell ...) function invocation, so I'm leaving this open as an enhancement request to create a variable containing the exit code of the last $(shell ...) invocation.

Paul D. Smith <psmith>
Project Administrator
Wed 25 Nov 2009 06:06:02 PM UTC, original submission:

Currently,

$(shell false) does not break build:

===
a := $(shell false)

x:
echo $(a)
===

completes successfully. Should fail, because in scenario:

a := $(shell cat version.txt)

it is hard to catch a situation if version.txt file does not exist.

Seen on gmake 3.81.

Stepan Koltsov <yozh>

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    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):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 25 Nov 2009 06:38:28 PM UTCpsmithItem GroupNone=>Enhancement

    Back to the top


    Powered by Savane 3.1-cleanup