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

repo-add does not behave the same as Arch's version #2

Closed
joaodefelipe opened this issue Jan 18, 2024 · 6 comments
Closed

repo-add does not behave the same as Arch's version #2

joaodefelipe opened this issue Jan 18, 2024 · 6 comments
Assignees

Comments

@joaodefelipe
Copy link

Hello! I've noticed an inconsistency in how repo-{add,remove} behaves.

It is my understanding that when -- occurs in the command line, all arguments after it are to be treated as positional arguments.
However, before --, it's expected a flag might occur anywhere — even mixed with positional arguments.

I caught this behavior because I use Paru, and with the SignDb option enabled, it puts the -s flag after all the positional arguments — maybe not ideal, but not incorrect usage either.

Reproduction: repo-add SOME_DB SOME_PACKAGE -s works with Arch's repo-add, but not with CachyOS's.

#1 seems to fix this, but there's likely some edge case I haven't thought of. Please, do tell if that's the case.

@vnepogodin
Copy link
Member

That isn't correct behavior for original repo-add either. repo-add expects in that order:
<options/flags>

@joaodefelipe
Copy link
Author

Following the man page and help message, what you said does make sense.

So, accepting options/flags after positional arguments is a bug in the original repo-add, and passing a flag after positional arguments is a bug in Paru... I guess the latter can (and should) be fixed easily enough, but I'm not sure if there are more tools out there doing the same.

Depending on how long ago this bug got introduced in Arch's repo-add, I don't think it's a bad idea to provide a drop-in replacement, and warn about incorrect usage — ultimately, it's up to you.

@vnepogodin
Copy link
Member

Following the man page and help message, what you said does make sense.

So, accepting options/flags after positional arguments is a bug in the original repo-add, and passing a flag after positional arguments is a bug in Paru... I guess the latter can (and should) be fixed easily enough, but I'm not sure if there are more tools out there doing the same.

Depending on how long ago this bug got introduced in Arch's repo-add, I don't think it's a bad idea to provide a drop-in replacement, and warn about incorrect usage — ultimately, it's up to you.

actually keep in mind that repo-add from archlinux core repo doesn't support -- flag at all. the new version of pacman will provide it, but its expected to release quite soon.
so maybe paru will break when they will release, maybe not.

I also think that original repo-add has a bug with -s after positional arguments. implementation of -- in original repo-add works equally as I implemented -> it does break out of loop if it reaches --. ref https://gitlab.archlinux.org/pacman/pacman/-/blob/master/scripts/repo-add.sh.in?ref_type=heads#L644

@vnepogodin
Copy link
Member

I can remove --. that should fix it, but paru will much probably be broken then anyways

@joaodefelipe
Copy link
Author

I also think that original repo-add has a bug with -s after positional arguments. implementation of -- in original repo-add works equally as I implemented -> it does break out of loop if it reaches --. ref https://gitlab.archlinux.org/pacman/pacman/-/blob/master/scripts/repo-add.sh.in?ref_type=heads#L644

#1 also breaks out of the loop in that case.

I can remove --. that should fix it, but paru will much probably be broken then anyways

#1 works with current Paru (or a possible future Paru that uses --). This is because arguments before -- that don't match flags or options are treated as positional arguments.

command meaning
repo-add mydb mypkg -s add package mypkg to database mydb; sign the database (this is what Paru does)
repo-add mydb mypkg -s -k foo add package mypkg to database mydb; sign the database with key foo
repo-add mydb mypkg -- -s add packages mypkg and -s to database mydb
repo-add -s -- -s -k add package -k to database -s; sign the database

@vnepogodin
Copy link
Member

fixed in #1

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

No branches or pull requests

2 participants