summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Cornellà <marc.cornella@live.com>2020-12-14 15:42:10 +0100
committerMarc Cornellà <marc.cornella@live.com>2020-12-14 15:52:30 +0100
commit076f7f1eb19914877e49eb186eb076fc3e493b36 (patch)
tree384946e6f143832396b9d1c0848da9cab9d88e7d
parent619097cc2ad31c1b5086870293739d41dd4129c3 (diff)
downloadzsh-076f7f1eb19914877e49eb186eb076fc3e493b36.tar.gz
zsh-076f7f1eb19914877e49eb186eb076fc3e493b36.tar.bz2
zsh-076f7f1eb19914877e49eb186eb076fc3e493b36.zip
fix(genpass): warn if no wordlist is found
-rw-r--r--plugins/genpass/genpass.plugin.zsh7
1 files changed, 6 insertions, 1 deletions
diff --git a/plugins/genpass/genpass.plugin.zsh b/plugins/genpass/genpass.plugin.zsh
index f1ad80bba..1353ef456 100644
--- a/plugins/genpass/genpass.plugin.zsh
+++ b/plugins/genpass/genpass.plugin.zsh
@@ -73,7 +73,7 @@ genpass-monkey() {
genpass-xkcd() {
# Generates a 128-bit XKCD-style passphrase
- # EG, 9-mien-flood-Patti-buxom-dozes-ickier-pay-ailed-Foster
+ # e.g, 9-mien-flood-Patti-buxom-dozes-ickier-pay-ailed-Foster
# Can take a numerical argument for generating extra passwords
if (( ! $+commands[shuf] )); then
@@ -81,6 +81,11 @@ genpass-xkcd() {
return 1
fi
+ if [[ ! -e /usr/share/dict/words ]]; then
+ echo >&2 "$0: no wordlist found in \`/usr/share/dict/words\`. Install one first."
+ return 1
+ fi
+
local -i i num
[[ $1 =~ '^[0-9]+$' ]] && num=$1 || num=1