From 619097cc2ad31c1b5086870293739d41dd4129c3 Mon Sep 17 00:00:00 2001 From: Patrick Harrison Date: Mon, 14 Dec 2020 09:52:02 +0700 Subject: [PATCH 1/3] fix(genpass): check for presence of shuf command. "shuf" is not a standard command on MacOS and requires installation of the brew coreutils package --- plugins/genpass/genpass.plugin.zsh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/genpass/genpass.plugin.zsh b/plugins/genpass/genpass.plugin.zsh index e7f86bf7a..f1ad80bba 100644 --- a/plugins/genpass/genpass.plugin.zsh +++ b/plugins/genpass/genpass.plugin.zsh @@ -75,6 +75,12 @@ genpass-xkcd() { # Generates a 128-bit XKCD-style passphrase # EG, 9-mien-flood-Patti-buxom-dozes-ickier-pay-ailed-Foster # Can take a numerical argument for generating extra passwords + + if (( ! $+commands[shuf] )); then + echo >&2 "$0: \`shuf\` command not found. Install coreutils (\`brew install coreutils\` on macOS)." + return 1 + fi + local -i i num [[ $1 =~ '^[0-9]+$' ]] && num=$1 || num=1 From 076f7f1eb19914877e49eb186eb076fc3e493b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 14 Dec 2020 15:42:10 +0100 Subject: [PATCH 2/3] fix(genpass): warn if no wordlist is found --- plugins/genpass/genpass.plugin.zsh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 From 2db42c6ce745ed37262bed6c97683a00a430f076 Mon Sep 17 00:00:00 2001 From: Patrick Harrison Date: Mon, 14 Dec 2020 10:11:12 +0700 Subject: [PATCH 3/3] fix(genpass): add compatibility for macOS paste command "paste" on macOS requires a '-' to signify that the standard input is used. Without the '-' character, the command errors out. --- plugins/genpass/genpass.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/genpass/genpass.plugin.zsh b/plugins/genpass/genpass.plugin.zsh index 1353ef456..e6a1cef34 100644 --- a/plugins/genpass/genpass.plugin.zsh +++ b/plugins/genpass/genpass.plugin.zsh @@ -101,6 +101,6 @@ genpass-xkcd() { for i in {1..$num}; do printf "$n-" - printf "$dict" | shuf -n "$n" | paste -sd '-' + printf "$dict" | shuf -n "$n" | paste -sd '-' - done }