Created
October 16, 2019 08:15
-
-
Save brujoand/b1d8296423825e6e47f921316a9c2600 to your computer and use it in GitHub Desktop.
When you need to set a shell variable but don't want the contents displayed anywhere.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set_secret() { | |
local variable_name=$1 | |
if [[ -z "$variable_name" ]]; then | |
read -r -p "Variable name: " variable_name | |
fi | |
read -s -r -p "Password: " variable_value | |
declare -g "$variable_name"="$variable_value" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment