mirror of
https://github.com/nushell/nushell.git
synced 2024-12-23 15:39:06 +01:00
Add special error for calling metadata
on $env and $nu (#11228)
Trying to call `metadata $env` or `metadata $nu` will throw an error: ```Nushell ~> metadata $nu Error: × Built-in variables `$env` and `$nu` have no metadata ╭─[entry #1:1:1] 1 │ metadata $nu · ─┬─ · ╰── no metadata available ╰──── ```
This commit is contained in:
parent
f8c82588b6
commit
c9aa6ba0f3
@ -3,6 +3,7 @@ use std::collections::{HashMap, HashSet};
|
||||
use crate::engine::EngineState;
|
||||
use crate::engine::DEFAULT_OVERLAY_NAME;
|
||||
use crate::{ShellError, Span, Value, VarId};
|
||||
use crate::{ENV_VARIABLE_ID, NU_VARIABLE_ID};
|
||||
|
||||
/// Environment variables per overlay
|
||||
pub type EnvVars = HashMap<String, HashMap<String, Value>>;
|
||||
@ -80,6 +81,16 @@ impl Stack {
|
||||
}
|
||||
}
|
||||
|
||||
if var_id == NU_VARIABLE_ID || var_id == ENV_VARIABLE_ID {
|
||||
return Err(ShellError::GenericError(
|
||||
"Built-in variables `$env` and `$nu` have no metadata".into(),
|
||||
"no metadata available".into(),
|
||||
Some(span),
|
||||
None,
|
||||
Vec::new(),
|
||||
));
|
||||
}
|
||||
|
||||
Err(ShellError::VariableNotFoundAtRuntime { span })
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user