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
Feature flags #4940
Feature flags #4940
Conversation
This sounds like a brilliant idea, and I'd love it for
I don't think we need to do it for any of the other changes. Would it be possible to add a link to further documentation to the description? Or hook it up to |
features_t::flag_t flag; | ||
|
||
/// User-presentable short name of the feature flag. | ||
const wchar_t *name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason these are wchar_t instead of wcstring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There will be string literals, so it's a little cheaper to initialize since it can be in a read-only segment, and doesn't need malloc().
One issue with The best I can come up with is Also can |
If I'm distributing a fish script, is there a way for me to set the feature flags I want for my script? The shebang line isn't much good because only the first argument is useful. |
If I'm understanding @ridiculousfish correctly, the idea is that you wouldn't - if you're touching the script, you should just port it to where it doesn't need "feature" flags (I think "compatibility" flags might be a better name) instead of adding any flags - that would become obsolete soon. |
Yeah that's the hope. Ideally writing a script that works on multiple versions is not hard. If it is hard then the features were badly designed. |
Nice spotting. This is annoying enough that we should just continue to support '?' in all cases. That is,
What did you have in mind? The feature flags don't make any particular syntax an error, they just change its meaning. |
That might be surprising when it comes to regexes - I'd rather just
Warn when one of these features is used. E.g. with the following script: somecommand ^/dev/null run
as a sort of static analysis to aid in porting away from deprecated features. See e.g. #4950 - we didn't catch the remaining caret redirection because it had a space, and I think all of us just used ad-hoc regexes to check for them. |
9ebc215
to
bd352d6
Compare
This introduces a new type features_t that exposes feature flags. The intent is to allow a deprecation/incremental adoption path. This is not a general purpose configuration mechanism, but instead allows for compatibility during the transition as features are added/removed. Each feature has a user-presentable short name and a short description. Their values are tracked in a struct features_t. We start with one feature stderr_nocaret, but it's not hooked up yet.
This teaches the status command to work with features. 'status features' will show a table listing all known features and whether they are currently on or off. `status test-feature` will test an individual feature, setting the exit status to 0 if the feature is on, 1 if off, 2 if unknown.
This introduces a new command line option --features which can be used for enabling or disabling features for a particular fish session. Examples: fish --features stderr-nocaret fish --features 3.0,no-stderr-nocaret fish --features all Note that the feature set cannot be changed in an existing session.
This partially reverts 5b489ca, with carets acting as redirections unless the stderr-nocaret flag is set. This flag is off by default but may be enabled on the command line: fish --features stderr-nocaret
This enables users to opt in (or out) of specific features by setting the fish_features environment variable. For example `set -U fish_features stderr-nocaret` to opt into removing the caret redirection.
This adds a feature flag for controlling whether question marks are globs. It is not yet hooked up.
This partially reverts 6e56637 and fish-shell#4520 by bringing back the ? wildcard, guarded by the qmark-noglob feature flag.
This is a convenience over fish_features().test()
Replace these with 2>
This merges support for feature flags. Closes fish-shell#4940
bd352d6
to
060643a
Compare
This is my proposal for feature flags, as a mechanism for introducing breaking changes ("features"). This may include removing existing syntax, or introducing new incompatible syntax.
Feature flags are set at startup via the command line and variables (environment or universal), and cannot be changed after: you have to make a new session. They can be queried at any point in the code. Features are also grouped. For example, we would have a "3.0" group for features introduced in 3.0; this lets authors test for 3.0 compatibility in one go. The "all" group is bleeding edge.
Feature flags are only intended to be used for transitions. The "off" state is the old behavior, the "on" state is the new behavior, and in a few releases we'll remove support for running with the feature off. They are not a long-term configuration mechanism.
This is how we would use feature flags to introduce a breaking change:
stderr-nocaret
is in group3.0
. The feature defaults to off, but we'll publish the upcoming change, and its feature flag name.fish --features stderr-nocaret
orfish --features 3.0
set -U fish_features stderr-nocaret
.status
can be used to list features, and check if they are on or off (should rarely be necessary).fish --features no-stderr-nocaret
.All functions and completions that ship with fish need to be compatible with any feature combination, as much as is possible.
This PR introduces the feature flag mechanism, and adds a feature flag for the stderr-nocaret behavior, defaulting to off. That is, carets are still redirections, but users can opt into the new behavior where carets are ordinary characters.
This PR contains the machinery and some tests. I'm eager to hear feedback on this approach before moving forwards with docs, etc.