check_line_len.awk 412 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/awk -f
  2. # Copyright (c) 2015 Arista Networks, Inc.
  3. # Use of this source code is governed by the Apache License 2.0
  4. # that can be found in the COPYING file.
  5. BEGIN {
  6. max = 100;
  7. }
  8. # Expand tabs to 4 spaces.
  9. {
  10. gsub(/\t/, " ");
  11. }
  12. length() > max {
  13. errors++;
  14. print FILENAME ":" FNR ": Line too long (" length() "/" max ")";
  15. }
  16. END {
  17. if (errors >= 125) {
  18. errors = 125;
  19. }
  20. exit errors;
  21. }