Skip to content

Disable alias recursion (for real) - #8557

Merged
kubouch merged 2 commits into
nushell:mainfrom
kubouch:alias-fix
Mar 22, 2023
Merged

kubouch merged 2 commits into
nushell:mainfrom
kubouch:alias-fix

Conversation

@kubouch

@kubouch kubouch commented Mar 21, 2023 •

Copy link
Copy Markdown
Contributor

Description

Completely disables recursion on aliases (hopefully better than the last time).

A side effect is that aliases are no longer "predeclared" like custom commands. This means that unlike custom commands, aliases are position-dependent and overwrite each other depending on which one is defined last. For example

alias l = ls -a
alias l = ls -l

is now valid and results in l expanding to ls -l when called.

I believe this is similar to how old aliases used to work.

Fixes #8246

User-Facing Changes

Changes alias semantics a bit.

Tests + Formatting

Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

  • cargo fmt --all -- --check to check standard code formatting (cargo fmt --all applies these changes)
  • cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

Note
from nushell you can also use the toolkit as follows

use toolkit.nu  # or use an `env_change` hook to activate it automatically
toolkit check pr

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

@kubouch
kubouch marked this pull request as ready for review March 21, 2023 21:51
@kubouch kubouch added notes:breaking-changes Noted in Breaking Changes section A:alias Issues around support for command aliases, touches parser and name resolution labels Mar 21, 2023
@codecov

codecov Bot commented Mar 21, 2023 •

Copy link
Copy Markdown

Codecov Report

Merging #8557 (a86c55e) into main (93e5d8e) will increase coverage by 0.38%.
The diff coverage is 98.03%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8557      +/-   ##
==========================================
+ Coverage   68.13%   68.51%   +0.38%     
==========================================
  Files         624      624              
  Lines      100512   100565      +53     
==========================================
+ Hits        68481    68902     +421     
+ Misses      32031    31663     -368     
Impacted Files Coverage Δ
crates/nu-command/src/formats/to/nuon.rs 88.32% <97.70%> (+5.08%) ⬆️
crates/nu-command/src/bytes/length.rs 87.14% <100.00%> (ø)
crates/nu-command/src/filters/uniq.rs 98.22% <100.00%> (ø)
crates/nu-parser/src/parse_keywords.rs 68.25% <100.00%> (-0.27%) ⬇️

... and 7 files with indirect coverage changes

@kubouch
kubouch merged commit c48e9cd into nushell:main Mar 22, 2023
@kubouch
kubouch deleted the alias-fix branch March 22, 2023 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:alias Issues around support for command aliases, touches parser and name resolution notes:breaking-changes Noted in Breaking Changes section

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cannot alias to the same command anymore

1 participant