Bug 119059 - %* evaluates with leading whitespace.
%* evaluates with leading whitespace.
Status: CLOSED WORKSFORME
Product: Fedora
Classification: Fedora
Component: rpm (Show other bugs)
rawhide
All Linux
low Severity medium
: ---
: ---
Assigned To: Jeff Johnson
Mike McLean
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-03-24 11:09 EST by James Olin Oden
Modified: 2007-11-30 17:10 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-03-28 23:35:38 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description James Olin Oden 2004-03-24 11:09:16 EST
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-25 22:18:04 EST
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 08:53:27 EST
I have tested this in the head and commited it....james 
Comment 3 Jeff Johnson 2004-03-28 23:35:38 EST
Thanks for the patch.

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