File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2042,7 +2042,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
20422042 // sort errors with "cannot open: [...]" instead of "cannot read: [...]" here
20432043 let reader = open_with_open_failed_error ( & files0_from) ?;
20442044 let buf_reader = BufReader :: new ( reader) ;
2045- for ( line_num, line) in buf_reader. split ( b'\0' ) . flatten ( ) . enumerate ( ) {
2045+ for ( line_num, line_res) in buf_reader. split ( b'\0' ) . enumerate ( ) {
2046+ let line = line_res. map_err ( |error| SortError :: ReadFailed {
2047+ path : files0_from. clone ( ) ,
2048+ error,
2049+ } ) ?;
20462050 let f = std:: str:: from_utf8 ( & line)
20472051 . expect ( "Could not parse string from zero terminated input." ) ;
20482052 match f {
Original file line number Diff line number Diff line change @@ -1569,6 +1569,15 @@ fn test_files0_from_empty() {
15691569 . stderr_only ( "sort: no input from 'file'\n " ) ;
15701570}
15711571
1572+ #[ test]
1573+ #[ cfg( unix) ]
1574+ fn test_files0_read_error ( ) {
1575+ new_ucmd ! ( )
1576+ . args ( & [ "--files0-from" , "." ] )
1577+ . fails_with_code ( 2 )
1578+ . stderr_only ( "sort: cannot read: .: Is a directory\n " ) ;
1579+ }
1580+
15721581#[ cfg( target_os = "linux" ) ]
15731582#[ test]
15741583// Test for GNU tests/sort/sort-files0-from.pl "empty-non-regular"
You can’t perform that action at this time.
0 commit comments