Fix environment merging in hooks (#6309)

This commit is contained in:
Jakub Žádník 2022-08-13 01:13:28 +03:00 committed by GitHub
parent c3efb12733
commit ccebdd7a7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -786,9 +786,6 @@ pub fn eval_hook(
for var_id in var_ids.iter() {
stack.vars.remove(var_id);
}
let cwd = get_guaranteed_cwd(engine_state, stack);
engine_state.merge_env(stack, cwd)?;
}
Value::Block {
val: block_id,
@ -796,8 +793,6 @@ pub fn eval_hook(
..
} => {
run_hook_block(engine_state, stack, block_id, arguments, block_span)?;
let cwd = get_guaranteed_cwd(engine_state, stack);
engine_state.merge_env(stack, cwd)?;
}
other => {
return Err(ShellError::UnsupportedConfigValue(
@ -825,6 +820,9 @@ pub fn eval_hook(
}
}
let cwd = get_guaranteed_cwd(engine_state, stack);
engine_state.merge_env(stack, cwd)?;
Ok(())
}