|
#!/bin/bash
|
|
|
|
set -o nounset
|
|
set -o errexit
|
|
|
|
|
|
# Commands -----------------------------------------------
|
|
ASPELL=/usr/bin/aspell
|
|
BASENAME=/usr/bin/basename
|
|
DIRNAME=/usr/bin/dirname
|
|
PWD=/bin/pwd
|
|
|
|
|
|
# Script -------------------------------------------------
|
|
extra=""
|
|
switch="--add-extra-dicts"
|
|
|
|
# file specific dictionary
|
|
# if there is a file with the same name
|
|
# but ending in `.pws`
|
|
# use it as an extra dict
|
|
directory=`$DIRNAME "$1"`
|
|
filename=`$BASENAME "$1"`
|
|
name="${filename%.*}"
|
|
dictpath=$directory/$name.pws
|
|
if [ -f "$dictpath" ]
|
|
then
|
|
extra="--add-extra-dicts=`$PWD`/${dictpath}"
|
|
fi
|
|
|
|
# extra dicts from the current directory
|
|
# all files in the working directory
|
|
# ending in `.pws` are used as extra dicts
|
|
|
|
# return nothing if *.pws does not match anything
|
|
shopt -s nullglob
|
|
|
|
for filename in *.pws;
|
|
do
|
|
extra="${extra} --add-extra-dicts=`$PWD`/${filename}"
|
|
done
|
|
|
|
$ASPELL $extra check "$1"
|