Bug 1169111 - %(echo %1 | tr A-Z a-z) returns %1
Summary: %(echo %1 | tr A-Z a-z) returns %1
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Packaging Maintenance Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-11-30 12:21 UTC by Jens Petersen
Modified: 2014-12-02 07:39 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2014-12-02 07:39:26 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

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() ...).


Note You need to log in before you can comment on or make changes to this bug.