浏览代码

fix(genpass): warn if no wordlist is found

Marc Cornellà 4 年之前
父节点
当前提交
076f7f1eb1
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      plugins/genpass/genpass.plugin.zsh

+ 6 - 1
plugins/genpass/genpass.plugin.zsh

@@ -73,7 +73,7 @@ genpass-monkey() {
 
 
 genpass-xkcd() {
 genpass-xkcd() {
   # Generates a 128-bit XKCD-style passphrase
   # 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
   # Can take a numerical argument for generating extra passwords
 
 
   if (( ! $+commands[shuf] )); then
   if (( ! $+commands[shuf] )); then
@@ -81,6 +81,11 @@ genpass-xkcd() {
     return 1
     return 1
   fi
   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
   local -i i num
 
 
   [[ $1 =~ '^[0-9]+$' ]] && num=$1 || num=1
   [[ $1 =~ '^[0-9]+$' ]] && num=$1 || num=1