From 6b516b3e8a8ae07d4b5af2bcac8edee1bce63d89 Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Thu, 26 Mar 2015 18:25:58 +0000 Subject: [PATCH] Refactered the password generator script. --- bin/genpw | 24 ++++++++++++++++++++++++ bin/genpw.sh | 8 -------- 2 files changed, 24 insertions(+), 8 deletions(-) create mode 100755 bin/genpw delete mode 100755 bin/genpw.sh diff --git a/bin/genpw b/bin/genpw new file mode 100755 index 0000000..38a8a4c --- /dev/null +++ b/bin/genpw @@ -0,0 +1,24 @@ +#!/bin/bash + +ECHOARGS= +LENGTH=12 + +while getopts nl: ARG; do + case ${ARG} in + n) ECHOARGS="-n" + ;; + + l) LENGTH=${OPTARG} + ;; + + ?) printf "Usage: %s [-n]\n" ${0} + exit 1 + ;; + esac +done + +PW=$(jot -rc 256 48 123 | grep -m${LENGTH} "\w" | rs -g 0 ${LENGTH}) + +echo ${ECHOARGS} ${PW} + +exit 0 diff --git a/bin/genpw.sh b/bin/genpw.sh deleted file mode 100755 index f443bad..0000000 --- a/bin/genpw.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -LENGTH=12 -[ ${1} ] && LENGTH=${1} - -PW=$(jot -rc 256 48 123 | grep -m${LENGTH} "\w" | rs -g 0 ${LENGTH}) - -echo -n ${PW}