mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 00:13:21 +01:00
add const variable $current_file for script files
script here refers to the entrypoint file when running scripts with nu like `nu script.nu`
This commit is contained in:
parent
7901f29445
commit
8cf2f9b261
@ -74,6 +74,18 @@ pub fn evaluate_file(
|
||||
.expect("internal error: missing filename");
|
||||
|
||||
let mut working_set = StateWorkingSet::new(engine_state);
|
||||
|
||||
let current_file = working_set.add_variable(
|
||||
b"$current_file".into(),
|
||||
Span::unknown(),
|
||||
nu_protocol::Type::String,
|
||||
false,
|
||||
);
|
||||
working_set.set_variable_const_val(
|
||||
current_file,
|
||||
Value::string(file_path.to_string_lossy(), Span::unknown()),
|
||||
);
|
||||
|
||||
trace!("parsing file: {}", file_path_str);
|
||||
let block = parse(&mut working_set, Some(file_path_str), &file, false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user