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

Only allow unaliasing in current scope, add tests #3936

Merged
merged 1 commit into from
Aug 19, 2021

Conversation

filaretov
Copy link
Contributor

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 the nu! macro joins all lines from the raw string and skips the first one. Essentially, everything passed into pipeline 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 of ls -l, I used echo, 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 the pipeline 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!

* unalias only removes aliases in the current scope

* Add a test and fix previous ones which did not function as expected
@sophiajt
Copy link
Contributor

Good catch. Thanks for noticing (and fixing!) that

@sophiajt sophiajt merged commit 6db5692 into nushell:main Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants