You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
569 B
Bash
24 lines
569 B
Bash
#!/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
|
|
|