Bug 1169111

Summary: %(echo %1 | tr A-Z a-z) returns %1
Product: [Fedora] Fedora Reporter: Jens Petersen <petersen>
Component: rpmAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: jzeleny, lkardos, novyjindrich, packaging-team-maint, pknirsch, pnemade
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-12-02 07:39:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jens Petersen 2014-11-30 12:21:55 UTC
Description of problem:
I am wondering if this a bug or expected rpmbuild behaviour:

Version-Release number of selected component (if applicable):
rpm-4.12.0.1-2.fc22
rpm-4.11.3-1.fc20
also on RHEL5

How reproducible:
100%

Steps to Reproduce:
1. Define:

   %global lower() %(echo %1 | tr A-Z a-z)

2. %lower CamelCase

3. %(echo CamelCase | tr A-Z a-z)


Actual results:
2. CamelCase
3. camelcase

Expected results:
2. camelcase

Additional info:
Above is a testcase: I am actually trying to define something
more complicated than %lower inside a packaging macro.

Comment 1 Ľuboš Kardoš 2014-12-01 09:27:24 UTC
Yes, this is expected behavior. Body of %global is expanded at definition time. So expansion has following steps:

%global lower() %(echo %1 | tr A-Z a-z) => %global %1 
%lower CamelCase => CamelCase

Use "%define" for lazy expansion:

%define lower() %(echo %1 | tr A-Z a-z)
%lower CamelCase => %(echo CamelCase | tr A-Z a-z) => camelcase

Comment 2 Jens Petersen 2014-12-02 03:11:13 UTC
Okay maybe I gave a bad test-case but I was actually using %define
in my original more complex example but it is not working: re-opening.

Comment 3 Jens Petersen 2014-12-02 07:39:26 UTC
Nevermind sorry, you're right.

This was caused by my using

%global mymacro()\
%define lower %(echo %1 | tr A-Z a-z)\
:
:

(instead of %define mymacro() ...).