]> git.proxmox.com Git - rustc.git/blobdiff - src/doc/rustc-dev-guide/ci/check_line_lengths.sh
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / doc / rustc-dev-guide / ci / check_line_lengths.sh
index 32bf739e4dc24989defd04d85d2b81d41b3e79d7..31cda5c65e911d62363fb8b741c9755282efacf7 100755 (executable)
@@ -1,19 +1,19 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 if [ "$1" == "--help" ]; then
-    echo 'Usage:'
-    echo '  MAX_LINE_LENGTH=100' "$0" 'src/**/*.md'
-    exit 1
+  echo 'Usage:' "[MAX_LINE_LENGTH=n] $0 [file ...]"
+  exit 1
 fi
 
 if [ "$MAX_LINE_LENGTH" == "" ]; then
-    echo '`MAX_LINE_LENGTH` environment variable not set. Try --help.'
-    exit 1
+    MAX_LINE_LENGTH=100
 fi
 
 if [ "$1" == "" ]; then
-    echo 'No files provided.'
-    exit 1
+  shopt -s globstar
+  files=( src/**/*.md )
+else
+  files=( "$@" )
 fi
 
 echo "Checking line lengths in all source files <= $MAX_LINE_LENGTH chars..."
@@ -21,7 +21,7 @@ echo "Checking line lengths in all source files <= $MAX_LINE_LENGTH chars..."
 echo "Offending files and lines:"
 (( bad_lines = 0 ))
 (( inside_block = 0 ))
-for file in "$@" ; do
+for file in "${files[@]}"; do
   echo "$file"
   (( line_no = 0 ))
   while IFS="" read -r line || [[ -n "$line" ]] ; do