Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro %-x modifies original flag if argument follows without intervening space #2454

Closed
rhabacker opened this issue Mar 24, 2023 · 4 comments
Assignees

Comments

@rhabacker
Copy link
Contributor

See the following example:

$rpm --version
RPM version 4.14.3

$ rpm --define '%foo(b:) %{-b}' --eval '%foo -b2'
-b 2

The macro adds a space between flag and argument, which may affect passing to applications as shown by the following example:

$ python3 -bb
Python 3.6.15 (default, Sep 23 2021, 15:41:43) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
<CTRL-D>

Passing the option through a rpm macro returns:

$ rpm --define '%foo(b:) python3 %{-b}' --eval '%foo -bb` 
python3 -b b

Running the generated command fails:

$`rpm --define '%foo(b:) python3 %{-b}' --eval '%foo -bb'` 
python3: can't open file 'b': [Errno 2] No such file or directory
@ffesti
Copy link
Contributor

ffesti commented Oct 11, 2023

See #2455

@pmatilai
Copy link
Member

Looking again at case and the PR, I do think the rpm behavior to enforce a uniform output for %x is intentional and sane. The macro arguments exist for modifying macro behavior, not for passing through to other programs, and we can't allow external program requirements to set the rules for rpm macros.

If you do pass an option through to some other program, it's the macros responsibility to handle any conversion needed.

@pmatilai
Copy link
Member

pmatilai commented Nov 2, 2023

Discussed this with the team to the same conclusion, closing.

@pmatilai pmatilai closed this as completed Nov 2, 2023
@pmatilai
Copy link
Member

pmatilai commented Nov 3, 2023

Perhaps more to the point: rpm macros accept flag arguments with or without an intervening space. If we accepted a change to this, that would no longer be true: some macro may then require the caller to supply arguments in a certain way just because it's passed through to some other program, but the caller has no way to know that. That's why it is, and must be, the responsibility of the macro writer to handle argument passdown to other programs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants