cat: cat_path does not need to parse InputType for stdin itself

This type is already handled by get_input_type, so we can unify the handling
This commit is contained in:
Michael Lohmann
2022-02-15 22:27:46 +01:00
committed by Michael Lohmann
parent 34b18351e2
commit 4676924532
+8 -8
View File
@@ -325,15 +325,15 @@ fn cat_path(
state: &mut OutputState,
out_info: Option<&FileInformation>,
) -> CatResult<()> {
if path == "-" {
let stdin = io::stdin();
let mut handle = InputHandle {
reader: stdin,
is_interactive: atty::is(atty::Stream::Stdin),
};
return cat_handle(&mut handle, options, state);
}
match get_input_type(path)? {
InputType::StdIn => {
let stdin = io::stdin();
let mut handle = InputHandle {
reader: stdin,
is_interactive: atty::is(atty::Stream::Stdin),
};
cat_handle(&mut handle, options, state)
}
InputType::Directory => Err(CatError::IsDirectory),
#[cfg(unix)]
InputType::Socket => {