Project

General

Profile

« Previous | Next » 

Revision 251

env_password: Added optional message arg

View differences:

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

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

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

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

Also available in: Unified diff