andrewgregory / pacutils

Helper library for libalpm based programs.
MIT License
107 stars 17 forks source link

pactrans: Interpret arguments after -- as targets #67

Closed Vekhir closed 1 month ago

Vekhir commented 1 year ago

When encountering -- on the commandline, getopt stops parsing the arguments. It is customary to then interpret all following arguments as positional (i.e. the targets for pactrans).

This allows to define targets without having to worry about potential issues with --xy in the names. It shouldn't happen, but it's another layer of security, especially for script environments.

Examples: pactrans --install -- pacutils works like pactrans --install pacutils pactrans --install -- --noconfirm pacutils fails pactrans --install --noconfirm -- pacutils works like pactrans --install --noconfirm pacutils

At the moment, pactrans just fails with error: no targets provided.

andrewgregory commented 2 months ago

Silently discarding arguments as it does now is clearly wrong, but I'm not sure exactly how -- should work for pactrans. The way that --install, --remove, --spec, and --file work makes it a little awkward and I think the official way to pass arbitrary package names will be via file descriptor when I finally finish that. Also, --xy is not a valid package name; makepkg will not build such a package and libalpm will reject it as well.

andrewgregory commented 1 month ago

Fixed.