Skip to content

Commit 3fe1b4d

Browse files
committed
Add capitalization code
1 parent 5f682cb commit 3fe1b4d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

memorable_password_gen.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,15 @@ random_punctuation() {
4747

4848
}
4949

50+
capitalize_word() {
51+
echo $(tr '[:lower:]' '[:upper:]' <<< ${1:0:1})${1:1}
52+
}
53+
5054
generate_random_password() {
5155
local word1
5256
local word2
57+
local word1_capitalized
58+
local word2_capitalized
5359
local punctuation
5460
local digit
5561
local local_result
@@ -62,13 +68,15 @@ generate_random_password() {
6268
random_line_from_file base_compound_nouns.txt
6369
word1=$(echo "${RANDOM_LINE_RESULT}" | egrep --only-matching '^\w+')
6470
word2=$(echo "${RANDOM_LINE_RESULT}" | egrep --only-matching '\w+$')
71+
word1_capitalized=$(capitalize_word $word1)
72+
word2_capitalized=$(capitalize_word $word2)
6573

6674
random_punctuation
6775
punctuation="${PUNCTUATION_RESULT}"
6876

6977
digit=$(jot -r 1 0 9)
7078

71-
local_result="${word1}${digit}${punctuation}${word2}"
79+
local_result="${word1_capitalized}${digit}${punctuation}${word2_capitalized}"
7280

7381
done
7482
RANDOM_PASSWORD_RESULT="${local_result}"

0 commit comments

Comments
 (0)