Only allow unaliasing in current scope, add tests #3936
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Just a quick fix for the recently merged
unalias
command.The previous implementation would loop over the frames and remove aliases from all of them. This is surprising, because other similar commands, such as
unlet-env
, do not do this, but instead only change the current scope. This also had the side effect of removing aliases when a user types (but does not run)unalias some-alias
.The test associated with unalias also had some issues, as far as I can tell. The
pipeline
function used with thenu!
macro joins all lines from the raw string and skips the first one. Essentially, everything passed intopipeline
is run as a single line. Due to this, the tests were passing, but not for the correct reason. I did not figure out a way to write the tests without defining a command, but that pattern was used in other tests, so I hope it's okay. I also changed the example commands in the tests: instead ofls -l
, I usedecho
, because it has predictable and testable output. I would be happy to rewrite that or add new tests if something else is preferable.On a related note, the
skip(1)
filter in thepipeline
function might have to be removed to avoid similar issues. Removing it does not cause any of the existing tests to fail, as far as I could tell.And thanks to the Nushell team and everyone who worked on this feature!