Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions crates/bashkit/src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3643,14 +3643,17 @@ impl Interpreter {
for redirect in redirects {
match redirect.kind {
RedirectKind::Input => {
let target_path = self.expand_word(&redirect.target).await?;
let path = self.resolve_path(&target_path);
let content = self.fs.read_file(&path).await?;
let text = bytes_to_latin1_string(&content);
if let Some(fd) = redirect.fd {
let target_path = self.expand_word(&redirect.target).await?;
let path = self.resolve_path(&target_path);
let content = self.fs.read_file(&path).await?;
let text = bytes_to_latin1_string(&content);
let lines: Vec<String> =
text.lines().rev().map(|l| l.to_string()).collect();
self.coproc_buffers.insert(fd, lines);
} else {
// exec < file: redirect stdin for subsequent commands
self.pipeline_stdin = Some(text);
}
}
RedirectKind::DupInput => {
Expand Down
10 changes: 10 additions & 0 deletions crates/bashkit/tests/spec_cases/bash/exec-command.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,13 @@ echo "after exec redirect"
### expect
after exec redirect
### end

### exec_stdin_redirect
# exec < file should redirect stdin for subsequent commands
echo "from file" > /tmp/exec_stdin_test.txt
exec < /tmp/exec_stdin_test.txt
read -r line
echo "got: $line"
### expect
got: from file
### end
Loading