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
Should most CLI options silently override earlier instances of the same option? #6269
Comments
I'ld like some more feedback from other borg users about this. I personally have no strong preference for either way, I just did the change because it felt cleaner than silently overriding everything except the last value. So, tell your preference and your reasons why that is for either:
or
|
I'm not a massive user of the CLI: once my scripts are written backup is mostly shot & forget. But I would agree with hexagonrecursion and the |
while I haven't been bit by the current behaviour, I will say that this surprised me. I would probably prefer to have a warning in these cases. I think "HIGHLANDER" is probably better, because if someone really was writing the above example "HIGHLANDER" also opens up the possibility to some day support multiple I do not see any upside to "LAST WINS", to be honest. It just silently discards a parameter someone has in there by mistake (best case) or intentionally (rendering the result incomplete). And you do not get to re-define what multiple |
I would also like to add that I do not see why |
Some options in borg are lists internally, e.g. |
The internal reason is completely irrelevant, though. The external inconsistency is the problem. |
I'm always a fan of programs that spot flaws in the way I call them. |
Note: I am working on this in #7499. |
more Highlander options, fixes #6269
…set once, even if the set value is a default value. Add tests for action=Highlander. See borgbackup#7500 borgbackup#6269
…set once, even if the set value is a default value. Add tests for action=Highlander. See borgbackup#7500 borgbackup#6269
…set once, even if the set value is a default value. Add tests for action=Highlander. See borgbackup#7500 borgbackup#6269
…set once, even if the set value is a default value. Add tests for action=Highlander. See borgbackup#7500 borgbackup#6269
…set once, even if the set value is a default value. Add tests for action=Highlander. See borgbackup#7500 borgbackup#6269
…set once, even if the set value is a default value. Add tests for action=Highlander. See borgbackup#7500 borgbackup#6269
…set once, even if the set value is a default value. Add tests for action=Highlander. See borgbackup#7500 borgbackup#6269
👍 This post for LAST_WINS
👎 This post for HIGHLANDER
(see below)
Is this a BUG / ISSUE report or a QUESTION?
QUESTION
Describe the problem you're observing.
#6241 introduced a breaking change in borg 1.2: several CLI options now cause an error if specified multiple times. Before #6241 the last instance of an option would silently override all previous instances of the same option:
Old behavior (the last instance silently wins):
borg list -P foo -P bar "$REPO" bar Wed, 2022-02-09 17:26:35 [1bfd9c34f1575db8f6e400b311fdf46d3998d1fad17bf6ee08c9e4909fd8a0c9]
New behavior:
Here is why I think this is a breaking change:
Silently ignoring all but the last instance of an option is a common pattern in CLI (unless repeating the option has special semantics like
borg create --exclude
). This is the default behavior of Python's argparse too.The reason this is useful is that people often write wrapper scripts for the tools they use. Those wrappers pass some arguments to the underlying tool. The wrappers often allow pass-through of arbitrary arguments (e.g.
borg <options here> "$@"
). The last-one-wins behavior allows the user of a wrapper to override an option set in the wrapper (e.g. the wrapper sets the default borg --prefix, but it can be overridden with my-wrapper --prefix).This change breaks the above use case potentially breaking scripts borg users have written.
What should we do?
At the very least I think it would be a bad idea to backport this to borg1.1 - isn't not breaking existing code and workflows the whole point of a stable release?
We should also discuss whether the use case described above is important enough to revert #6241. If we do not, we should add a note to the release notes warning the users about the change.
The text was updated successfully, but these errors were encountered: