From 6afddc4d6a761225e16eaa7e2e70ac1ae1e69571 Mon Sep 17 00:00:00 2001 From: Bulat Musin Date: Thu, 4 Jan 2018 14:47:19 +0300 Subject: [PATCH] tail: squashed two commits commit ceaeb5ec2a284555e6c061070c74b050efb129f0 Author: Bulat Musin Date: Thu Jan 4 11:01:29 2018 +0300 tail: fix typo commit 50e3568e460c7ec9786835c9795d1496a2463901 Author: Bulat Musin Date: Thu Jan 4 10:54:17 2018 +0300 collapse similar changes into one commit commit a54df8d92d534b801b364c2e74635dfe282441d8 Author: Bulat Musin Date: Wed Jan 3 21:05:33 2018 +0300 tail: add --silent option commit 5c9aec7e5bb5ff79f1421e5b33bf82809795bc64 Author: Bulat Musin Date: Wed Jan 3 20:43:36 2018 +0300 tail: add spaces after hashes --- src/tail/README.md | 5 ++--- src/tail/tail.rs | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/tail/README.md b/src/tail/README.md index 9bd15e725..6d227c66a 100644 --- a/src/tail/README.md +++ b/src/tail/README.md @@ -1,14 +1,13 @@ Rudimentary tail implementation. -##Missing features: +## Missing features: ### Flags with features * `--max-unchanged-stats` : with `--follow=name`, reopen a FILE which has not changed size after N (default 5) iterations to see if it has been unlinked or renamed (this is the usual case of rotated log files). With inotify, this option is rarely useful. -* `--quiet` : never output headers giving file names * `--retry` : keep trying to open a file even when it is or becomes inaccessible; useful when follow‐ing by name, i.e., with `--follow=name` ### Others The current implementation does not handle `-` as an alias for stdin. -##Possible optimizations: +## Possible optimizations: * Don't read the whole file if not using `-f` and input is regular file. Read in chunks from the end going backwards, reading each individual chunk forward. diff --git a/src/tail/tail.rs b/src/tail/tail.rs index 80287ac7b..bb0f115ea 100755 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -79,8 +79,8 @@ pub fn uumain(args: Vec) -> i32 { opts.optflag("h", "help", "help"); opts.optflag("V", "version", "version"); opts.optflag("v", "verbose", "always output headers giving file names"); - // TODO: --silent flag as alias to --quiet opts.optflag("q", "quiet", "never output headers giving file names"); + opts.optflag("", "silent", "synonym of --quiet"); let given_options = match opts.parse(&args) { Ok (m) => { m } @@ -167,7 +167,7 @@ pub fn uumain(args: Vec) -> i32 { } let verbose = given_options.opt_present("v"); - let quiet = given_options.opt_present("q"); + let quiet = given_options.opt_present("q") || given_options.opt_present("silent"); let files = given_options.free; @@ -181,7 +181,7 @@ pub fn uumain(args: Vec) -> i32 { for filename in &files { if (multiple || verbose) && !quiet { - if !first_header { println!(""); } + if !first_header { println!(); } println!("==> {} <==", filename); } first_header = false;