Project

General

Profile

1
#!/bin/bash
2
# Sets a password environment variable
3

    
4
test "$#" -ge 1 || \
5
{ echo "Usage: . $0 env_var_name [msg] (note the initial \".\")" >&2; exit 2;}
6

    
7
msg="$2"
8
test -n "$msg" || msg="$1"
9

    
10
if test -z "${!1+t}"; then # env var with name $1 is unset
11
    read -s -p "Enter $msg password: "; echo
12
    export "$1"="$REPLY"
13
fi
(3-3/16)