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

%{dirname:foo} is returning foo #2928

Closed
mlschroe opened this issue Feb 23, 2024 · 2 comments
Closed

%{dirname:foo} is returning foo #2928

mlschroe opened this issue Feb 23, 2024 · 2 comments
Assignees

Comments

@mlschroe
Copy link
Contributor

We're testing for it in the test cases so it might be intentional, but is there any good reason why %{dirname:foo} returns foo instead of `` or .? At least the documentation says it is a "dirname(1) macro analogue"...

@ffesti
Copy link
Contributor

ffesti commented Mar 5, 2024

My suspicion is that %dirname was used there not to test for it returning the filename unchanged but it was chosen as leaving the parameter unchanged made it a good test case for undefined arguments.

ffesti added a commit to ffesti/rpm that referenced this issue Mar 5, 2024
Strip trailing '/' unless "/" itself
Keep "." untouched
Keep root dir for files in the root dir
Return "." for files without directory and empty strings

See man 3 dirname

Resolves: rpm-software-management#2928
@pmatilai
Copy link
Member

pmatilai commented Mar 5, 2024

Indeed, there's no deeper meaning to the test, it's all about argument handling and nothing to do with dirname itself (the context of c5909bd makes it quite clear)

ffesti added a commit to ffesti/rpm that referenced this issue Mar 5, 2024
ffesti added a commit to ffesti/rpm that referenced this issue Mar 5, 2024
This changes the behaviour of %dirname to something sane. No longer
return the argument unchanged if there is no / found. Also handle
several cornercases properly.

Resolves: rpm-software-management#2928
ffesti added a commit to ffesti/rpm that referenced this issue Mar 7, 2024
This changes the behaviour of %dirname to something sane. No longer
return the argument unchanged if there is no / found. Also handle
several cornercases properly.

Resolves: rpm-software-management#2928
@ffesti ffesti closed this as completed in 9571e3d Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

3 participants