Skip to content

Commit c53ca6d

Browse files
authored
Merge pull request uutils#5372 from sanpii/ls-panic
ls: fix panic when file removed too quickly
2 parents 90b3f6b + e1b7f25 commit c53ca6d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/uu/ls/src/ls.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2889,7 +2889,11 @@ fn classify_file(path: &PathData, out: &mut BufWriter<Stdout>) -> Option<char> {
28892889
Some('=')
28902890
} else if file_type.is_fifo() {
28912891
Some('|')
2892-
} else if file_type.is_file() && file_is_executable(path.md(out).as_ref().unwrap()) {
2892+
} else if file_type.is_file()
2893+
// Safe unwrapping if the file was removed between listing and display
2894+
// See https://github.com/uutils/coreutils/issues/5371
2895+
&& path.md(out).map(file_is_executable).unwrap_or_default()
2896+
{
28932897
Some('*')
28942898
} else {
28952899
None

0 commit comments

Comments
 (0)