mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
Disallow ^
in def
command names (#7606)
# Description Closes #7273. Also slightly edits/tidies up parser.rs. # User-Facing Changes `^` is now forbidden in `def` and `def-env` command names. EDIT: also `alias`. # 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 # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date.
This commit is contained in:
@ -43,35 +43,38 @@ fn alias_hiding_2() {
|
||||
|
||||
#[test]
|
||||
fn alias_fails_with_invalid_name() {
|
||||
let err_msg = "alias name can't be a number, a filesize, or contain a hash # or caret ^";
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
alias 1234 = echo "test"
|
||||
"#
|
||||
));
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("alias name can't be a number, a filesize, or contain a hash"));
|
||||
assert!(actual.err.contains(err_msg));
|
||||
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
alias 5gib = echo "test"
|
||||
"#
|
||||
));
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("alias name can't be a number, a filesize, or contain a hash"));
|
||||
assert!(actual.err.contains(err_msg));
|
||||
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
alias "te#t" = echo "test"
|
||||
"#
|
||||
));
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("alias name can't be a number, a filesize, or contain a hash"));
|
||||
assert!(actual.err.contains(err_msg));
|
||||
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
alias ^foo = "bar"
|
||||
"#
|
||||
));
|
||||
assert!(actual.err.contains(err_msg));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Reference in New Issue
Block a user