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