bugmake - Bugs: bug #56064, bash + .ONESHELL breaks when...

 
 

bug #56064: bash + .ONESHELL breaks when .SHELLFLAGS is set

Submitter:  Carl Ponder <carlponder>
Submitted:  Wed 03 Apr 2019 12:54:47 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.1 Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 03 Apr 2019 12:36:24 PM UTC, comment #4: 

Ok that fixes it.
I'd only been using bash-parameters in script headers


     #!/bin/bash -eux
-verbatim

so I didn't realize the -c requirement.
Go ahead and close this.
Thank you for the info (and sorry for the bother!).

Carl Ponder <carlponder>
Wed 03 Apr 2019 12:22:01 PM UTC, comment #3: 

I can't say whether that SO-referenced issue still exists or has been fixed, but your example usages of setting .SHELLFLAGS are all incorrect.  They are all missing the -c option, which you must provide to the shell otherwise it thinks that the argument you gave is a filename, not a command to run.  See the shell man page.

Consider:


$ /bin/bash -e 'echo hi'
/bin/bash: echo hi: No such file or directory


$ /bin/bash -ec 'echo hi'
hi


Paul D. Smith <psmith>
Group administrator
Wed 03 Apr 2019 01:03:59 AM UTC, comment #2: 

Here's the output of "make --version":

    GNU Make 4.1
    Built for x86_64-pc-linux-gnu
    Copyright (C) 1988-2014 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.

This is on Ubuntu 16.04.
I see the same problem with 3.82 on CentOS 7.

Carl Ponder <carlponder>
Wed 03 Apr 2019 01:00:10 AM UTC, comment #1: 

I see a post that looks like it's related to this:

https://stackoverflow.com/questions/32163727/shellflags-assignment-in-makefile


Carl Ponder <carlponder>
Wed 03 Apr 2019 12:54:47 AM UTC, original submission:  

Here is a basic usage of shell-sequencing inside a Makefile rule:

    SHELL:=/bin/bash

    .ONESHELL:
    default:
        VERSION=1.0
        echo '$${VERSION}=' $${VERSION}

When I run "make", it outputs

    VERSION=1.0
    echo '${VERSION}=' ${VERSION}
    ${VERSION}= 1.0

indicating that the variable had been set and expanded the way I expect.
If I add any one of these forms to the Makefile

    .SHELLFLAGS=-l
    .SHELLFLAGS=-e
    .SHELLFLAGS=-u
    .SHELLFLAGS=-x
    .SHELLFLAGS=--noprofile
    .SHELLFLAGS=--norc

I get the same error

    VERSION=1.0
    echo '${VERSION}=' ${VERSION}
    /bin/bash: VERSION=1.0
    echo '${VERSION}=' ${VERSION}: No such file or directory
    Makefile:10: recipe for target 'default' failed
    make: * [default] Error 127

This isn't a blocker to me, but I'm trying to figure out what's wrong.
As far as I can tell from the documentation, my usages are okay.

Carl Ponder <carlponder>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #46702:  Makefile added by carlponder (245B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-05-11 psmith StatusNone Not A Bug
        Open/ClosedOpen Closed
    2019-04-03 carlponder Attached File- Added Makefile, #46702

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code