mirror of
https://github.com/nushell/nushell
synced 2024-12-27 21:43:09 +00:00
Pass TERM
environment var to clear (#6500)
* Pass `TERM` environment var to clear * don't panic * use IOErrorSpanned instead of IOError
This commit is contained in:
parent
2030e25ddc
commit
80624267fd
1 changed files with 14 additions and 7 deletions
|
@ -23,24 +23,31 @@ impl Command for Clear {
|
||||||
|
|
||||||
fn run(
|
fn run(
|
||||||
&self,
|
&self,
|
||||||
_engine_state: &EngineState,
|
engine_state: &EngineState,
|
||||||
_stack: &mut Stack,
|
stack: &mut Stack,
|
||||||
call: &Call,
|
call: &Call,
|
||||||
_input: PipelineData,
|
_input: PipelineData,
|
||||||
) -> Result<PipelineData, ShellError> {
|
) -> Result<PipelineData, ShellError> {
|
||||||
|
let span = call.head;
|
||||||
|
|
||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
CommandSys::new("cmd")
|
CommandSys::new("cmd")
|
||||||
.args(["/C", "cls"])
|
.args(["/C", "cls"])
|
||||||
.status()
|
.status()
|
||||||
.expect("failed to execute process");
|
.map_err(|e| ShellError::IOErrorSpanned(e.to_string(), span))?;
|
||||||
} else if cfg!(unix) {
|
} else if cfg!(unix) {
|
||||||
CommandSys::new("/bin/sh")
|
let mut cmd = CommandSys::new("/bin/sh");
|
||||||
.args(["-c", "clear"])
|
|
||||||
|
if let Some(Value::String { val, .. }) = stack.get_env_var(engine_state, "TERM") {
|
||||||
|
cmd.env("TERM", val);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.args(["-c", "clear"])
|
||||||
.status()
|
.status()
|
||||||
.expect("failed to execute process");
|
.map_err(|e| ShellError::IOErrorSpanned(e.to_string(), span))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Value::Nothing { span: call.head }.into_pipeline_data())
|
Ok(Value::Nothing { span }.into_pipeline_data())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn examples(&self) -> Vec<Example> {
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
|
Loading…
Reference in a new issue