get_first_line: Simplify END logic

This commit is contained in:
Chris Down 2020-03-23 17:45:33 +00:00
parent a9fb4c9823
commit da1ccb7c70

View file

@ -48,19 +48,15 @@ get_first_line() {
# first line that can provide reasonable context to the user.
awk -v limit=300 '
BEGIN { printed = 0; }
printed == 0 && NF {
$0 = substr($0, 0, limit);
printf("%s", $0);
printed = 1;
}
END {
if (NR > 1) {
print " (" NR " lines)";
} else {
printf("\n");
}
if (NR > 1)
printf(" (%d lines)", NR);
printf("\n");
}' <<< "$data"
}