From 3f5b5264eaef213c018bb6b83d6c1409948e0d01 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Wed, 11 Nov 2020 20:48:50 +0100 Subject: [PATCH] Add tests/max-length --- tests/max-length | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 tests/max-length diff --git a/tests/max-length b/tests/max-length new file mode 100755 index 0000000..9360ef2 --- /dev/null +++ b/tests/max-length @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Check comment lines (lines starting with #) in cheat sheets +# and list files with such lines, and return exit code 1. +# Return exit code 0, if no cheat sheets with long lines found + +MAX_STRING_LENGTH=80 + +MY_DIR=$(dirname "$(dirname "$(realpath "${BASH_SOURCE[0]}")")") +SHEETS_DIR="$MY_DIR/sheets" + +long_lines_sheets=$( + cd "$SHEETS_DIR" && + grep -rPl "#.{${MAX_STRING_LENGTH}}" +) + +if [[ $(printf "%s\n" "$long_lines_sheets" | wc -l) -gt 1 ]]; then + echo "Files with long (> 80) lines:" + echo + printf "%s\n" "$long_lines_sheets" + exit 1 +fi +