Skip to content

Commit

Permalink
Merge pull request #5372 from sanpii/ls-panic
Browse files Browse the repository at this point in the history
ls: fix panic when file removed too quickly
  • Loading branch information
sylvestre authored Oct 8, 2023
2 parents 90b3f6b + e1b7f25 commit c53ca6d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/uu/ls/src/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2889,7 +2889,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
Expand Down

0 comments on commit c53ca6d

Please sign in to comment.