Skip to content

Commit 10c83f3

Browse files
author
oech3
committed
dirname: fix dirname . >/dev/full panic
1 parent c599d51 commit 10c83f3

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/uu/dirname/src/dirname.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use clap::{Arg, ArgAction, Command};
77
use std::ffi::OsString;
8+
use std::io::{Write as _, stdout};
89
#[cfg(unix)]
910
use uucore::display::print_verbatim;
1011
use uucore::error::{UResult, UUsageError};
@@ -122,20 +123,20 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
122123
{
123124
use std::os::unix::ffi::OsStrExt;
124125
let result_os = std::ffi::OsStr::from_bytes(result);
125-
print_verbatim(result_os).unwrap();
126+
print_verbatim(result_os)?;
126127
}
127128
#[cfg(not(unix))]
128129
{
129130
// On non-Unix, fall back to lossy conversion
130131
if let Ok(s) = std::str::from_utf8(result) {
131-
print!("{s}");
132+
write!(stdout(), "{s}")?;
132133
} else {
133134
// Fallback for non-UTF-8 paths on non-Unix systems
134-
print!(".");
135+
write!(stdout, ".")?;
135136
}
136137
}
137138

138-
print!("{line_ending}");
139+
write!(stdout(), "{line_ending}")?;
139140
}
140141

141142
Ok(())

0 commit comments

Comments
 (0)