Revision 290
Added by Aaron Marcuse-Kubitza about 13 years ago
env_password | ||
---|---|---|
2 | 2 |
# Sets a password environment variable |
3 | 3 |
|
4 | 4 |
test "$#" -ge 1 || \ |
5 |
{ echo "Usage: . $0 env_var_name [msg] (note the initial \".\")" >&2; exit 2;}
|
|
5 |
{ echo "Usage: . $BASH_SOURCE env_var [msg] (note initial \".\")" >&2; exit 2;}
|
|
6 | 6 |
|
7 | 7 |
msg="$2" |
8 | 8 |
test -n "$msg" || msg="$1" |
9 | 9 |
|
10 |
function trace() |
|
11 |
{ |
|
12 |
{ for arg in "$@"; do printf "%q " "$arg"; done; echo;} >&2 |
|
13 |
} |
|
14 |
|
|
10 | 15 |
if test -z "${!1+t}"; then # env var with name $1 is unset |
16 |
echo "[7m To avoid having to reenter $msg password, run: [0m" >&2 |
|
17 |
trace . "$BASH_SOURCE" "$@" |
|
11 | 18 |
read -s -p "Enter $msg password: "; echo |
12 | 19 |
export "$1"="$REPLY" |
13 | 20 |
fi |
Also available in: Unified diff
env_password: Print instructions for storing password for the session