mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 02:45:08 +02:00
Revert "Feature: PWD-per-drive to facilitate working on multiple drives at Windows" (#14598)
Reverts nushell/nushell#14411
This commit is contained in:
@ -156,9 +156,6 @@ pub fn env_to_strings(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
stack.pwd_per_drive.get_env_vars(&mut env_vars_str);
|
||||
|
||||
Ok(env_vars_str)
|
||||
}
|
||||
|
||||
|
@ -194,11 +194,6 @@ pub fn redirect_env(engine_state: &EngineState, caller_stack: &mut Stack, callee
|
||||
caller_stack.add_env_var(var, value);
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
caller_stack.pwd_per_drive = callee_stack.pwd_per_drive.clone();
|
||||
}
|
||||
|
||||
// set config to callee config, to capture any updates to that
|
||||
caller_stack.config.clone_from(&callee_stack.config);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::{borrow::Cow, fs::File, sync::Arc};
|
||||
|
||||
use nu_path::AbsolutePathBuf;
|
||||
use nu_path::{expand_path_with, AbsolutePathBuf};
|
||||
use nu_protocol::{
|
||||
ast::{Bits, Block, Boolean, CellPath, Comparison, Math, Operator},
|
||||
debugger::DebugContext,
|
||||
@ -14,7 +14,7 @@ use nu_protocol::{
|
||||
};
|
||||
use nu_utils::IgnoreCaseExt;
|
||||
|
||||
use crate::{eval::is_automatic_env_var, eval_block_with_early_return, redirect_env};
|
||||
use crate::{eval::is_automatic_env_var, eval_block_with_early_return};
|
||||
|
||||
/// Evaluate the compiled representation of a [`Block`].
|
||||
pub fn eval_ir_block<D: DebugContext>(
|
||||
@ -870,7 +870,7 @@ fn literal_value(
|
||||
Value::string(path, span)
|
||||
} else {
|
||||
let cwd = ctx.engine_state.cwd(Some(ctx.stack))?;
|
||||
let path = ctx.stack.expand_path_with(path, cwd, true);
|
||||
let path = expand_path_with(path, cwd, true);
|
||||
|
||||
Value::string(path.to_string_lossy(), span)
|
||||
}
|
||||
@ -890,7 +890,7 @@ fn literal_value(
|
||||
.cwd(Some(ctx.stack))
|
||||
.map(AbsolutePathBuf::into_std_path_buf)
|
||||
.unwrap_or_default();
|
||||
let path = ctx.stack.expand_path_with(path, cwd, true);
|
||||
let path = expand_path_with(path, cwd, true);
|
||||
|
||||
Value::string(path.to_string_lossy(), span)
|
||||
}
|
||||
@ -1405,8 +1405,7 @@ enum RedirectionStream {
|
||||
/// Open a file for redirection
|
||||
fn open_file(ctx: &EvalContext<'_>, path: &Value, append: bool) -> Result<Arc<File>, ShellError> {
|
||||
let path_expanded =
|
||||
ctx.stack
|
||||
.expand_path_with(path.as_str()?, ctx.engine_state.cwd(Some(ctx.stack))?, true);
|
||||
expand_path_with(path.as_str()?, ctx.engine_state.cwd(Some(ctx.stack))?, true);
|
||||
let mut options = File::options();
|
||||
if append {
|
||||
options.append(true);
|
||||
@ -1486,3 +1485,26 @@ fn eval_iterate(
|
||||
eval_iterate(ctx, dst, stream, end_index)
|
||||
}
|
||||
}
|
||||
|
||||
/// Redirect environment from the callee stack to the caller stack
|
||||
fn redirect_env(engine_state: &EngineState, caller_stack: &mut Stack, callee_stack: &Stack) {
|
||||
// TODO: make this more efficient
|
||||
// Grab all environment variables from the callee
|
||||
let caller_env_vars = caller_stack.get_env_var_names(engine_state);
|
||||
|
||||
// remove env vars that are present in the caller but not in the callee
|
||||
// (the callee hid them)
|
||||
for var in caller_env_vars.iter() {
|
||||
if !callee_stack.has_env_var(engine_state, var) {
|
||||
caller_stack.remove_env_var(engine_state, var);
|
||||
}
|
||||
}
|
||||
|
||||
// add new env vars from callee to caller
|
||||
for (var, value) in callee_stack.get_stack_env_vars() {
|
||||
caller_stack.add_env_var(var, value);
|
||||
}
|
||||
|
||||
// set config to callee config, to capture any updates to that
|
||||
caller_stack.config.clone_from(&callee_stack.config);
|
||||
}
|
||||
|
Reference in New Issue
Block a user