Don't leak set/set-env/source scopes via actions (#2849)

This commit is contained in:
Jonathan Turner
2021-01-03 19:44:21 +13:00
committed by GitHub
parent 77f915befe
commit fc44df1e45
11 changed files with 114 additions and 152 deletions

View File

@ -1,6 +1,6 @@
use crate::value::Value;
use nu_errors::ShellError;
use nu_source::{b, DebugDocBuilder, PrettyDebug, Tagged};
use nu_source::{b, DebugDocBuilder, PrettyDebug};
use serde::{Deserialize, Serialize};
/// The inner set of actions for the command processor. Each denotes a way to change state in the processor without changing it directly from the command itself.
@ -20,14 +20,8 @@ pub enum CommandAction {
EnterValueShell(Value),
/// Enter the help shell, which allows exploring the help system
EnterHelpShell(Value),
/// Add a variable into scope
AddVariable(String, Value),
/// Add an environment variable into scope
AddEnvVariable(String, String),
/// Add plugins from path given
AddPlugins(String),
/// Run the given script in the current context (given filename)
SourceScript(Tagged<String>),
/// Go to the previous shell in the shell ring buffer
PreviousShell,
/// Go to the next shell in the shell ring buffer
@ -49,9 +43,6 @@ impl PrettyDebug for CommandAction {
CommandAction::EnterShell(s) => b::typed("enter shell", b::description(s)),
CommandAction::EnterValueShell(v) => b::typed("enter value shell", v.pretty()),
CommandAction::EnterHelpShell(v) => b::typed("enter help shell", v.pretty()),
CommandAction::AddVariable(..) => b::description("add variable"),
CommandAction::AddEnvVariable(..) => b::description("add environment variable"),
CommandAction::SourceScript(..) => b::description("source script"),
CommandAction::AddPlugins(..) => b::description("add plugins"),
CommandAction::PreviousShell => b::description("previous shell"),
CommandAction::NextShell => b::description("next shell"),