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

%{gsub:...} throws error #3410

Open
voxik opened this issue Oct 29, 2024 · 8 comments
Open

%{gsub:...} throws error #3410

voxik opened this issue Oct 29, 2024 · 8 comments

Comments

@voxik
Copy link
Contributor

voxik commented Oct 29, 2024

From documentation, I would think this should work:

$ rpm --eval "%{gsub:foo o i}"
error: lua script failed: [string "gsub"]:1: bad argument #2 to 'gsub' (string expected, got no value)

Please note the example works just fine without the collon:

$ rpm --eval "%{gsub foo o i}"
fii

Testing on Fedora Rawhide:

$ rpm -q rpm
rpm-4.20.0-1.fc42.x86_64
@pmatilai
Copy link
Member

Yeah both syntaxes should work. Thanks for reporting.

@pmatilai pmatilai added the bug label Oct 30, 2024
@mlschroe
Copy link
Contributor

No, please do not change this. %{macro:something} is a way to expand a macro with exactly one argument. gsub needs more than one argument, thus the error.

@mlschroe
Copy link
Contributor

See also:

$ rpm --eval '%{len foo bar}' --eval '%{len:foo bar}'
3
7

@pmatilai
Copy link
Member

Hmm, I don't remember the : syntax being intentionally one argument only but then it's been a while.
But in that case this is a documentation issue.

@voxik
Copy link
Contributor Author

voxik commented Oct 30, 2024

Hmm, I don't remember the : syntax being intentionally one argument only but then it's been a while. But in that case this is a documentation issue.

I'd argue this is just documentation issue. The "one arguments" syntax likely has some merit, but then the error message is quite unintuitive

@voxik
Copy link
Contributor Author

voxik commented Oct 30, 2024

Hmm, I don't remember the : syntax being intentionally one argument only but then it's been a while. But in that case this is a documentation issue.

I'd argue this is just documentation issue. The "one arguments" syntax likely has some merit, but then the error message is quite unintuitive

IOW, the error should say that the "one argument" syntax is not supported for gsub

@voxik
Copy link
Contributor Author

voxik commented Oct 30, 2024

See also:

$ rpm --eval '%{len foo bar}'
3

And TBH, this is also quite questionable behavior.

@mlschroe
Copy link
Contributor

That's caused by %len being mapped to lua's string.len() function, and lua does not complain about the extra arg:

$ lua
> print(string.len("foo", "bar"))
3
> 

@pmatilai pmatilai added this to RPM Nov 6, 2024
@github-project-automation github-project-automation bot moved this to Backlog in RPM Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

3 participants