1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #902 from nkowdley/master

add verbose flag to tail
This commit is contained in:
Heather 2016-06-19 09:14:21 +04:00 committed by GitHub
commit eebfc69397
2 changed files with 4 additions and 2 deletions

View file

@ -7,7 +7,6 @@ Rudimentary tail implementation.
* `--pid` : with `-f`, terminate after process ID, PID dies * `--pid` : with `-f`, terminate after process ID, PID dies
* `--quiet` : never output headers giving file names * `--quiet` : never output headers giving file names
* `--retry` : keep trying to open a file even when it is or becomes inaccessible; useful when following by name, i.e., with `--follow=name` * `--retry` : keep trying to open a file even when it is or becomes inaccessible; useful when following by name, i.e., with `--follow=name`
* `--verbose` : always output headers giving file names
### Others ### Others
The current implementation does not handle `-` as an alias for stdin. The current implementation does not handle `-` as an alias for stdin.

View file

@ -71,6 +71,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
opts.optflag("z", "zero-terminated", "Line delimiter is NUL, not newline"); opts.optflag("z", "zero-terminated", "Line delimiter is NUL, not newline");
opts.optflag("h", "help", "help"); opts.optflag("h", "help", "help");
opts.optflag("V", "version", "version"); opts.optflag("V", "version", "version");
opts.optflag("v", "verbose", "always output headers giving file names");
let given_options = match opts.parse(&args) { let given_options = match opts.parse(&args) {
Ok (m) => { m } Ok (m) => { m }
@ -140,6 +141,8 @@ pub fn uumain(args: Vec<String>) -> i32 {
} }
} }
let verbose = given_options.opt_present("v");
let files = given_options.free; let files = given_options.free;
if files.is_empty() { if files.is_empty() {
@ -155,7 +158,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
} }
for filename in &files { for filename in &files {
if multiple { if multiple || verbose {
if !first_header { println!(""); } if !first_header { println!(""); }
println!("==> {} <==", filename); println!("==> {} <==", filename);
} }