ls: fix panic when file removed too quickly

Fixes #5371
This commit is contained in:
Sanpi 2023-10-07 10:39:19 +02:00
parent 91c8724fd5
commit e1b7f254a6
No known key found for this signature in database
GPG key ID: E470B43A221A1A91

View file

@ -2888,7 +2888,11 @@ fn classify_file(path: &PathData, out: &mut BufWriter<Stdout>) -> Option<char> {
Some('=')
} else if file_type.is_fifo() {
Some('|')
} else if file_type.is_file() && file_is_executable(path.md(out).as_ref().unwrap()) {
} else if file_type.is_file()
// Safe unwrapping if the file was removed between listing and display
// See https://github.com/uutils/coreutils/issues/5371
&& path.md(out).map(file_is_executable).unwrap_or_default()
{
Some('*')
} else {
None