Skip to content

Commit

Permalink
tail: Add documentation for Settings::check_warnings and Settings::ve…
Browse files Browse the repository at this point in the history
…rify
  • Loading branch information
Joining7943 committed Dec 10, 2022
1 parent e84705c commit e091057
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/uu/tail/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ impl Settings {
self.inputs.len()
}

/// Check [`Settings`] for problematic configurations of tail originating from user provided
/// command line arguments and print appropriate warnings.
pub fn check_warnings(&self) {
if self.retry {
if self.follow.is_none() {
Expand All @@ -262,6 +264,10 @@ impl Settings {
}
}

// This warning originates from gnu's tail implementation of the equivalent warning. If the
// user wants to follow stdin, but tail is blocking indefinitely anyways, because of stdin
// as `tty` (but no otherwise blocking stdin), then we print a warning that `--follow`
// cannot be applied under these circumstances and is therefore ineffective.
if self.follow.is_some() && self.has_stdin() {
let blocking_stdin = self.pid == 0
&& self.follow == Some(FollowMode::Descriptor)
Expand All @@ -279,6 +285,10 @@ impl Settings {
}
}

/// Verify [`Settings`] and try to find unsolvable misconfigurations of tail originating from
/// user provided command line arguments. In contrast to [`Settings::check_warnings`] these
/// misconfigurations usually lead to the immediate exit or abortion of the running `tail`
/// process.
pub fn verify(&self) -> VerificationResult {
// Mimic GNU's tail for `tail -F`
if self.inputs.iter().any(|i| i.is_stdin()) && self.follow == Some(FollowMode::Name) {
Expand Down

0 comments on commit e091057

Please sign in to comment.