Skip to content

Commit dcfd2fa

Browse files
reubenoCopilot
andauthored
fix: apply suggestions
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 6d7f5df commit dcfd2fa

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

brush-core/src/commands.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,8 +724,9 @@ pub(crate) async fn invoke_shell_function(
724724
)?;
725725

726726
// A function executes within the current shell process and shares its caller's open files,
727-
// so the parameters are passed through by shared reference rather than cloned. The shared
728-
// borrow also guarantees the body cannot disturb the caller's open-file table.
727+
// so the parameters are passed through by shared reference rather than cloned. This prevents
728+
// direct mutation of the caller's `ExecutionParameters` open-file table, though the function
729+
// may still change the shell's persistent open files via builtins (e.g. `exec`).
729730
let result = body.execute(context.shell, &context.params).await;
730731

731732
// We've come back out, reflect it.

brush-core/src/interp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,7 @@ pub(crate) async fn setup_redirect(
17771777
.parse::<ShellFd>()
17781778
.map_err(|_| error::ErrorKind::InvalidRedirection)?;
17791779

1780-
// Duplicate the fd.
1780+
// Reference the same open file as the source fd (shared handle; no OS-level duplication).
17811781
let Some(target_file) = params.try_fd(shell, source_fd_num) else {
17821782
return Err(error::ErrorKind::BadFileDescriptor(source_fd_num).into());
17831783
};

brush-shell/tests/cases/compat/fd_management.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ cases:
2525
args:
2626
- "-c"
2727
- |
28-
ulimit -n 256
28+
ulimit -n 256 || exit 1
2929
emit() {
3030
local v
3131
v=$(echo "$1")
@@ -41,7 +41,7 @@ cases:
4141
args:
4242
- "-c"
4343
- |
44-
ulimit -n 256
44+
ulimit -n 256 || exit 1
4545
work() {
4646
local v
4747
v=$(echo "alias-$1" 2>/dev/null)
@@ -57,7 +57,7 @@ cases:
5757
args:
5858
- "-c"
5959
- |
60-
ulimit -n 256
60+
ulimit -n 256 || exit 1
6161
rec() {
6262
local n=$1
6363
if [ "$n" -le 0 ]; then

0 commit comments

Comments
 (0)