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

add a `set --show` flag #4265

Closed
krader1961 opened this issue Jul 28, 2017 · 3 comments
Closed

add a `set --show` flag #4265

krader1961 opened this issue Jul 28, 2017 · 3 comments
Assignees
Labels
Milestone

Comments

@krader1961
Copy link
Contributor

@krader1961 krader1961 commented Jul 28, 2017

Many of us have written something like my show function:

$ show y
not set: local $y
not set: global $y
not set: universal $y
$ set -l y argle bargle
$ show y
set: local unexported $y count=2
$y[1] length=5 value=|argle|
$y[2] length=6 value=|bargle|
not set: global $y
not set: universal $y

However, this has at least two drawbacks:

  1. any local vars it sets shadows those in the surrounding context, and
  2. you can't actually display the values of each scope since the $var syntax provides no way to ask for the value(s) from a specific scope.

These drawbacks means it is much harder to give simple commands to help someone understand why their set commands aren't having the desired outcome. Such as in issue #4263. So I propose adding -S/--show flags to set to do the same thing as my show function but without the drawbacks. This would also be extremely useful in our unit tests where we also have a show function and employ other techniques to determine if a var is (un)set correctly.

@krader1961 krader1961 added this to the fish-3.0 milestone Jul 28, 2017
@krader1961 krader1961 self-assigned this Jul 28, 2017
@krader1961
Copy link
Contributor Author

@krader1961 krader1961 commented Aug 2, 2017

I am strongly inclined to include the fix for this in fish 2.7.0 despite the fact I have recently argued that other changes be deferred to 3.0.0. In this case the implementation is borderline trivial and no existing behavior is altered. If the user doesn't use the new --show flag then they can't be affected by the change I'd like to merge and will send out for review in a few minutes. And this feature is likely to be extremely useful in supporting people still using fish 2.x (assuming we can get them to upgrade to 2.7) and has zero risk of breaking anything. If you disagree please speak up.

@krader1961
Copy link
Contributor Author

@krader1961 krader1961 commented Aug 2, 2017

Sigh! I'm not going to merge this into master unless there is a deafening cry to do so. That's because I've already made some other cleanups to src/builtin_set.cpp that the change is based on that are not present in the master branch. Which means that merging this into the master branch, then merging that into major, is going to be a PITA. My attempt to git cherry-pick 0e8af72ca23a0f6912c05865730d0ee0875209ac resulted in an impenetrable merge conflict.

krader1961 added a commit that referenced this issue Aug 3, 2017
Kurtis Rader
This adds a new capability to the `set` command. It is similar to
running `set` with no other arguments but provides far more detail about
each variable. Such as whether it is set in each of the local, global,
and universal scopes. And the values in each scope. You can also ask for
specific variables to be shown.

Fixes #4265
@krader1961 krader1961 closed this Aug 3, 2017
@krader1961
Copy link
Contributor Author

@krader1961 krader1961 commented Aug 7, 2017

Note that I did ultimately backport this enhancement into the fish 2.7 development (aka master) branch. Since doing so does not alter any existing behavior and is useful for debugging problems.

@zanchey zanchey modified the milestones: fish 2.7.0, fish-3.0 Aug 9, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.