Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1bab7ba

Browse files
committed
tail: show end of device
gnu coreutils will show end of device for block devices.In current implementation this is skipped as a block devicesare recognized as untailable.The change ensures that we first try to output the end of anyfile and only then tell the observer that the file is notobservable.
1 parent1baedc4 commit1bab7ba

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

‎src/uu/tail/src/tail.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,28 +140,35 @@ fn tail_file(
140140
returnOk(());
141141
}
142142
observer.add_bad_path(path, input.display_name.as_str(),false)?;
143-
}elseif input.is_tailable(){
143+
}else{
144144
let metadata = path.metadata().ok();
145145
matchFile::open(path){
146146
Ok(mut file) =>{
147147
header_printer.print_input(input);
148148
letmut reader;
149+
let is_file_with_no_blocks = metadata
150+
.as_ref()
151+
.map_or(false, |m| m.file_type().is_file() && m.get_block_size() ==0);
149152
if !settings.presume_input_pipe
150153
&& file.is_seekable(if input.is_stdin(){ offset}else{0})
151-
&&metadata.as_ref().unwrap().get_block_size() >0
154+
&&!is_file_with_no_blocks
152155
{
153156
bounded_tail(&mut file, settings);
154157
reader =BufReader::new(file);
155158
}else{
156159
reader =BufReader::new(file);
157160
unbounded_tail(&mut reader, settings)?;
158161
}
159-
observer.add_path(
160-
path,
161-
input.display_name.as_str(),
162-
Some(Box::new(reader)),
163-
true,
164-
)?;
162+
if input.is_tailable(){
163+
observer.add_path(
164+
path,
165+
input.display_name.as_str(),
166+
Some(Box::new(reader)),
167+
true,
168+
)?;
169+
}else{
170+
observer.add_bad_path(path, input.display_name.as_str(),false)?;
171+
}
165172
}
166173
Err(e)if e.kind() ==ErrorKind::PermissionDenied =>{
167174
observer.add_bad_path(path, input.display_name.as_str(),false)?;
@@ -176,8 +183,6 @@ fn tail_file(
176183
}));
177184
}
178185
}
179-
}else{
180-
observer.add_bad_path(path, input.display_name.as_str(),false)?;
181186
}
182187

183188
Ok(())

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp