Bug 119059 - %* evaluates with leading whitespace.
Summary: %* evaluates with leading whitespace.
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: rawhide
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Jeff Johnson
QA Contact: Mike McLean
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-03-24 16:09 UTC by James Olin Oden
Modified: 2007-11-30 22:10 UTC (History)
0 users

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-03-29 04:35:38 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description James Olin Oden 2004-03-24 16:09:16 UTC
Description of problem:
The %* macro evaluates with leading whitespace.
Since the leading whitespace should not be considered part of the 
arguments to the macro, this IMHO wrong.  Where it becomes problematic
is when you are quoting the results of %*, as the command receiving
this will have an unexpected (unless you are aware of the bug) space
at the begining of the argument.  Can be worked around, but its just
a tad annoying.

Version-Release number of selected component (if applicable):


How reproducible:
Always


Steps to Reproduce:
1.  Create macro in /etc/rpm/macros like this:

%macroX(p:) \
echo "'%{-p:-p=%{-p*}}' '%{*}'" \
%{nil}

2.  Use the macro in, say a %post, like this:

%macroX -p stuff hello there
  
Actual results:
It will evaluate to:

   echo "'-p=stuff' ' hello there'"

And when executed display:

   '-p=stuff' ' hello there'

Expected results:
That it would evaluate to:

   echo "'-p=stuff' 'hello there'"

And when executed display:

   '-p=stuff' 'hello there'

Additional info:
Will probabably fix this my self.  Just wanted a place holder in 
bugzilla.

Comment 1 James Olin Oden 2004-03-26 03:18:04 UTC
Once I found it, it was a trivial fix: 
 
   Index: macro.c 
       
=================================================================== 
   RCS file: /cvs/devel/rpm/rpmio/macro.c,v 
   retrieving revision 2.100 
   diff -r2.100 macro.c 
   1013c1013 
   <           *be++ = ' '; 
   --- 
   >           if(be != b) *be++ = ' '; /* Add space between args */ 
 
I have tested this in 4.2.  I want to build it in the head (this diff is from the head) and 
make sure no obvious borkage is there, and then I will commit.  Basically, it was 
adding a space in front of every argument including the first.  The patch makes it not 
do that on the first argument (you know I have written this same bug in perl, shell 
and every language I can think of (-;). 
 
Cheers...james 
 
P.S.  I also found that there is this thing called %**.  It by the way does not have the 
leading space.  The comment talks about what the args looked like before macro 
processing, but macro processing seems to have happened on the result of %** so I 
really don't know what it is about. 

Comment 2 James Olin Oden 2004-03-27 13:53:27 UTC
I have tested this in the head and commited it....james 

Comment 3 Jeff Johnson 2004-03-29 04:35:38 UTC
Thanks for the patch.


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