[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Macros get expanded in comments..



Circa 2000-Sep-25 18:05:00 -0700 dixit Kenneth Porter:

: On Sun, 24 Sep 2000 23:44:22 -0500 (CDT), Tim Mooney wrote:
: >It's not a bug.  See past discussion on this list regarding this issue.
: >%define is context free, unlike what you may be used to with cpp et. al.
: 
: Ok, I can understand %define being evaluated inside quoted strings and
: can see how it would get into the false side of an %if clause from a
: coding oversight, but why in comments? Why aren't comments stripped out
: before macro processing? Under what conditions would it be useful to
: evaluate a macro expression in a comment?

How about:

  %define WrapperScript %{name}-wrapper
  ...
  %prep
  ...
  cat <<EOF >%{WrapperScript}
  #!/bin/sh
  # %{WrapperScript}: Wrapper around %{name} to frob the gesticulator
  
  GESTICULATOR_FROB_DIR="/var/lib/gesticulator/frob"
  
  %{name}
  EOF

Without processing '%define's in comments, that would have to be:


  %define WrapperScript %{name}-wrapper
  ...
  %prep
  ...
  ExpandMacros() {
    sed -e \
      's,@name@,%{name},g' \
      's,@WrapperScript@,%{WrapperScript},g'
  }
  cat <<EOF |ExpandMacros >%{WrapperScript}
  #!/bin/sh
  # @WrapperScript@: Wrapper around @name@ to frob the gesticulator
  
  GESTICULATOR_FROB_DIR="/var/lib/gesticulator/frob"
  
  @name@
  EOF

which is rather annoying.  I have plenty of my own specfiles from
pre-rpm-3.0.x days that do that.

Perhaps RPM could emit a non-fatal warning when expanding a macro in a
comment?  I'm not certain whether the macro parser could know that it's
in a comment, but that might help solve both ends of the problem....

-- 
jim knoble | jmknoble@jmknoble.cx | http://www.jmknoble.cx/





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []