From 7eb7e51dda9129bd7fcf74dd6b31646d151ab880 Mon Sep 17 00:00:00 2001 From: Hugh Davenport Date: Wed, 22 Jan 2020 15:47:00 +1300 Subject: [PATCH] Add environment variable for location of wordlist This allows you to call genhost from anywhere (it may be in your ~/bin). This fixes a bug with it wouldn't use the wordlist variable, and always use the file `wordlist`. --- genhost | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/genhost b/genhost index 9896023..beff4c9 100755 --- a/genhost +++ b/genhost @@ -4,7 +4,7 @@ # genhost - generate unused hostnames by randomly picking from a word list # -readonly wordlist='wordlist' +readonly wordlist=${GENHOST_WORDLIST:-$(dirname $0)/wordlist} readonly domain=${GENHOST_DOMAIN:-example.com} # http://mywiki.wooledge.org/BashFAQ/026 @@ -75,7 +75,7 @@ else ;; esac elif [[ $1 == "list" ]]; then - grep "#" wordlist | sed 's/#//' + grep "#" ${wordlist} | sed 's/#//' else printf 'genhost: invalid input\n' >&2 exit 1