githookignoreaspell

Git Hook Spellchecker Ignore Indented Lines


I am writing a git hook that spell checks my commit messages. This is what I have so far:

#!/bin/sh

ASPELL=$(which aspell)

WORDS=$($ASPELL list < "$1")

if [ -n "$WORDS" ]; then
    echo -e "Possible spelling errors found in commit message. Consider using git commit --amend to change the message.\n\tPossible mispelled words: " $WORDS
fi

I'm not sure how to tell aspell that I want to ignore lines that are indented (two or more spaces). This will avoid annoying messages about file names, comments, etc.

Thank you!


Solution

  • Are you doing EECS 398 by any chance?

    Just giving you a hint without breaking the honor code.

    Put the commit message into a text file. Use a text editor to delete the indented lines from the text file. Then put the text file through aspell.