#!/bin/sh
#
# This preprocesses a set of word lists into a suitable form for input
# into cracklib-packer
#
# Truncates lines longer than 1022 characters long as cracklib-packer
# does not handle them correctly.
#
# The last part of the pipeline uses 'grep -v' to remove any blank
# lines (possibly introduced by earlier parts of the pipeline) as
# cracklib-packer will generate "skipping line" warnings otherwise.
#
gzip -cdf "$@" |
    grep -a -v '^#' |
    tr '[A-Z]' '[a-z]' |
    tr -cd '\012[a-z][0-9]' |
    cut -c 1-1022 |
    grep -v '^$' |
    env LC_ALL=C sort -u
