mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
Fix print_table_or_error when table
is overridden (#6130)
Related #6113 Signed-off-by: nibon7 <nibon7@163.com>
This commit is contained in:
parent
72c27bd095
commit
86a0e77065
2 changed files with 26 additions and 14 deletions
|
@ -77,7 +77,11 @@ pub fn print_table_or_error(
|
|||
|
||||
match engine_state.find_decl("table".as_bytes(), &[]) {
|
||||
Some(decl_id) => {
|
||||
let table = engine_state.get_decl(decl_id).run(
|
||||
let command = engine_state.get_decl(decl_id);
|
||||
if command.get_block_id().is_some() {
|
||||
print_or_exit(pipeline_data, engine_state, config);
|
||||
} else {
|
||||
let table = command.run(
|
||||
engine_state,
|
||||
stack,
|
||||
&Call::new(Span::new(0, 0)),
|
||||
|
@ -97,6 +101,7 @@ pub fn print_table_or_error(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
None => {
|
||||
print_or_exit(pipeline_data, engine_state, config);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::tests::{fail_test, run_test, run_test_contains, TestResult};
|
||||
use nu_test_support::nu;
|
||||
|
||||
#[test]
|
||||
fn no_scope_leak1() -> TestResult {
|
||||
|
@ -135,3 +136,9 @@ fn help_not_present_in_extern() -> TestResult {
|
|||
fn override_table() -> TestResult {
|
||||
run_test(r#"def table [] { "hi" }; table"#, "hi")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn override_table_eval_file() {
|
||||
let actual = nu!(cwd: ".", r#"def table [] { "hi" }; table"#);
|
||||
assert_eq!(actual.out, "hi");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue