github.com/psiphon-labs/goarista@v0.0.0-20160825065156-d002785f4c67/check_line_len.awk (about)

     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  
     6  BEGIN {
     7    max = 100;
     8  }
     9  
    10  # Expand tabs to 4 spaces.
    11  {
    12    gsub(/\t/, "    ");
    13  }
    14  
    15  length() > max {
    16    errors++;
    17    print FILENAME ":" FNR ": Line too long (" length() "/" max ")";
    18  }
    19  
    20  END {
    21    if (errors >= 125) {
    22      errors = 125;
    23    }
    24    exit errors;
    25  }