Skip to content

Commit

Permalink
Reflect EnterSubshellOption::Ignore to current_state.action
Browse files Browse the repository at this point in the history
Previously, the current state's action was set to Action::Default when
EnterSubshellOption::Ignore was passed to GrandState::enter_subshell.
This commit changes it to Action::Ignore, so that the action indicates
the actual configuration of the trap.

This change is necessary for the trap built-in to print all traps
correctly, including ones that are not configured by the user.
  • Loading branch information
magicant committed Jan 31, 2025
1 parent 988dc4b commit b9c9579
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion yash-env/src/trap/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ impl GrandState {
},
));
}
if option == EnterSubshellOption::Ignore {
self.current_state.action = Action::Ignore;
}

let new_setting = (&self.current_state.action).into();
let new_disposition = match option {
Expand Down Expand Up @@ -905,7 +908,7 @@ mod tests {
map[&cond].get_state(),
(
Some(&TrapState {
action: Action::Default, // TODO Should be Action::Ignore,
action: Action::Ignore,
origin: Origin::Subshell,
pending: false
}),
Expand Down

0 comments on commit b9c9579

Please sign in to comment.