root/scripts/util/env_password @ 265
1 | 183 | aaronmk | #!/bin/bash
|
---|---|---|---|
2 | 131 | aaronmk | # Sets a password environment variable
|
3 | |||
4 | 251 | aaronmk | test "$#" -ge 1 || \ |
5 | { echo "Usage: . $0 env_var_name [msg] (note the initial \".\")" >&2; exit 2;} |
||
6 | 131 | aaronmk | |
7 | 251 | aaronmk | msg="$2" |
8 | test -n "$msg" || msg="$1" |
||
9 | |||
10 | 131 | aaronmk | if test -z "${!1+t}"; then # env var with name $1 is unset |
11 | 251 | aaronmk | read -s -p "Enter $msg password: "; echo |
12 | 131 | aaronmk | export "$1"="$REPLY" |
13 | fi
|