Revision 293
Added by Aaron Marcuse-Kubitza almost 13 years ago
bin/env_password | ||
---|---|---|
3 | 3 |
|
4 | 4 |
self="$(readlink -f -- "$BASH_SOURCE")" |
5 | 5 |
|
6 |
noInstr=
|
|
7 |
test _"$1" = _- && { noInstr=1; shift;}
|
|
6 |
force=
|
|
7 |
test _"$1" = _- && { force=1; shift;}
|
|
8 | 8 |
|
9 | 9 |
test "$#" -ge 1 || \ |
10 | 10 |
{ echo "Usage: . $self env_var_name [msg] (note initial \".\")" >&2; exit 2;} |
... | ... | |
17 | 17 |
{ for arg in "$@"; do printf "%q " "$arg"; done; echo;} >&2 |
18 | 18 |
} |
19 | 19 |
|
20 |
if test -z "${!1+t}"; then # env var with name $1 is unset |
|
21 |
if test -z "$noInstr"; then |
|
22 |
echo "[7m To avoid having to reenter $msg password, run: [0m" >&2 |
|
23 |
trace . "$self" - "$@" |
|
20 |
if test -n "$force" -o -z "${!1+t}"; then # env var with name $1 is unset |
|
21 |
if test -n "$force"; then action="change the saved value for" |
|
22 |
else action="avoid having to reenter" |
|
24 | 23 |
fi |
24 |
echo "[7m To $action $msg password, run: [0m" >&2 |
|
25 |
trace . "$self" - "$@" |
|
26 |
|
|
25 | 27 |
read -s -p "Enter $msg password: "; echo |
26 | 28 |
export "$1"="$REPLY" |
27 | 29 |
fi |
Also available in: Unified diff
env_password: Allow user to change saved password