mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 14:25:55 +02:00
Allow NU_LIBS_DIR and friends to be const (#8538)
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use nu_engine::{eval_block, find_in_dirs_env, redirect_env, CallExt};
|
||||
use nu_engine::{eval_block, find_in_dirs_env, get_dirs_var_from_call, redirect_env, CallExt};
|
||||
use nu_parser::trim_quotes_str;
|
||||
use nu_protocol::ast::{Call, Expr};
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
@ -66,23 +66,24 @@ impl Command for OverlayUse {
|
||||
let mut name_arg: Spanned<String> = call.req(engine_state, caller_stack, 0)?;
|
||||
name_arg.item = trim_quotes_str(&name_arg.item).to_string();
|
||||
|
||||
let maybe_origin_module_id = if let Some(overlay_expr) = call.parser_info_nth(0) {
|
||||
if let Expr::Overlay(module_id) = overlay_expr.expr {
|
||||
module_id
|
||||
let maybe_origin_module_id =
|
||||
if let Some(overlay_expr) = call.get_parser_info("overlay_expr") {
|
||||
if let Expr::Overlay(module_id) = overlay_expr.expr {
|
||||
module_id
|
||||
} else {
|
||||
return Err(ShellError::NushellFailedSpanned {
|
||||
msg: "Not an overlay".to_string(),
|
||||
label: "requires an overlay (path or a string)".to_string(),
|
||||
span: overlay_expr.span,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return Err(ShellError::NushellFailedSpanned {
|
||||
msg: "Not an overlay".to_string(),
|
||||
label: "requires an overlay (path or a string)".to_string(),
|
||||
span: overlay_expr.span,
|
||||
msg: "Missing positional".to_string(),
|
||||
label: "missing required overlay".to_string(),
|
||||
span: call.head,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return Err(ShellError::NushellFailedSpanned {
|
||||
msg: "Missing positional".to_string(),
|
||||
label: "missing required overlay".to_string(),
|
||||
span: call.head,
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
let overlay_name = if let Some(name) = call.opt(engine_state, caller_stack, 1)? {
|
||||
name
|
||||
@ -113,7 +114,12 @@ impl Command for OverlayUse {
|
||||
|
||||
// Evaluate the export-env block (if any) and keep its environment
|
||||
if let Some(block_id) = module.env_block {
|
||||
let maybe_path = find_in_dirs_env(&name_arg.item, engine_state, caller_stack)?;
|
||||
let maybe_path = find_in_dirs_env(
|
||||
&name_arg.item,
|
||||
engine_state,
|
||||
caller_stack,
|
||||
get_dirs_var_from_call(call),
|
||||
)?;
|
||||
|
||||
let block = engine_state.get_block(block_id);
|
||||
let mut callee_stack = caller_stack.gather_captures(&block.captures);
|
||||
|
Reference in New Issue
Block a user