Hello. I often written macros defined like this:

```rpm
%py_shebang_fix %{expand:\\\
  if [ -z "%{?py_shebang_flags}" ]; then
    shebang_flags="-k"
  else
    shebang_flags="-ka%{py_shebang_flags}"
  fi
  %{__python} -B %{_rpmconfigdir}/redhat/pathfix.py -pni %{__python} 
$shebang_flags}
```

I've abused `%expand` to have a macro definition that expands across multiple 
lines.

@pmatilai [said](https://bugzilla.redhat.com/show_bug.cgi?id=2160716#c10):

> Using an outer `%{expand:...}` just to make it look like a function (as seems 
> to be a common habit in Fedora) is bad thing to do because it then breaks 
> when you least expect it to. NEVER use `%{expand:...}` unless you actually 
> mean it, as in, need that extra expand. And even then, only use it on the 
> smallest possible block to achieve what you need, not the entire thing "just 
> because"

If I had to drop the  `%expand`, I'd probably have to do something like:

```rpm
%py_shebang_fix \
  if [ -z "%{?py_shebang_flags}" ]; then \
    shebang_flags="-k" \
  else \
    shebang_flags="-ka%{py_shebang_flags}" \
  fi \
  %{__python} -B %{_rpmconfigdir}/redhat/pathfix.py -pni %{__python} 
$shebang_flags
```

That is a bit **ugly**. Another option is to take a macro that is always 
defined and make the thing conditional on it:

```rpm
%py_shebang_fix %{?nil:\\\
  if [ -z "%{?py_shebang_flags}" ]; then
    shebang_flags="-k"
  else
    shebang_flags="-ka%{py_shebang_flags}"
  fi
  %{__python} -B %{_rpmconfigdir}/redhat/pathfix.py -pni %{__python} 
$shebang_flags}
```

That is **hard to understand** by the reader.

Could we get some kind of macro that allows us to achieve what we use `%expand` 
for?

E.g.

```rpm
%py_shebang_fix %{multiline:\
  if [ -z "%{?py_shebang_flags}" ]; then
    shebang_flags="-k"
  else
    shebang_flags="-ka%{py_shebang_flags}"
  fi
  %{__python} -B %{_rpmconfigdir}/redhat/pathfix.py -pni %{__python} 
$shebang_flags}
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/discussions/2353
You are receiving this because you are subscribed to this thread.

Message ID: <rpm-software-management/rpm/repo-discussions/2...@github.com>
_______________________________________________
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to