BASH: password generator

function genpasswd() {
    tr -dc [:alnum:][:punct:] < /dev/urandom | head -c ${1:-8} | xargs -0
}

The password will be 8 characters long if no argument is specified.