Skip to content

Commit ea87b0c

Browse files
committed
od: port GNU stdin compatibility to wasi
1 parent 6276737 commit ea87b0c

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/uu/od/src/multifile_reader.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ impl MultifileReader<'_> {
5757
// the buffering is done elsewhere and in a way that is aware of the `-N`
5858
// limit.
5959
let stdin = io::stdin();
60-
#[cfg(unix)]
60+
#[cfg(any(unix, target_os = "wasi"))]
6161
{
6262
let stdin_raw_fd = stdin.as_raw_fd();
63+
// FIXME: unexpected close with this unsafe fd
6364
let stdin_file = unsafe { File::from_raw_fd(stdin_raw_fd) };
6465
self.curr_file = Some(Box::new(stdin_file));
6566
}
@@ -68,10 +69,9 @@ impl MultifileReader<'_> {
6869
// we don't need to prevent stdin buffering. This is sub-optimal (since
6970
// there will still be additional buffering further up the stack), but
7071
// doesn't seem worth worrying about at this time.
71-
#[cfg(not(unix))]
72-
{
73-
self.curr_file = Some(Box::new(stdin));
74-
}
72+
#[cfg(not(any(unix, target_os = "wasi")))]
73+
self.curr_file = Some(Box::new(stdin));
74+
7575
break;
7676
}
7777
InputSource::FileName(fname) => {

0 commit comments

Comments
 (0)