Project

General

Profile

« Previous | Next » 

Revision 291

env_password: Print absolute path to env_password in case invoking script changed the working directory

View differences:

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

  
4
self="$(readlink -f -- "$BASH_SOURCE")"
5

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

  
7 9
msg="$2"
8 10
test -n "$msg" || msg="$1"
......
14 16

  
15 17
if test -z "${!1+t}"; then # env var with name $1 is unset
16 18
    echo " To avoid having to reenter $msg password, run: " >&2
17
    trace . "$BASH_SOURCE" "$@"
19
    trace . "$self" "$@"
18 20
    read -s -p "Enter $msg password: "; echo
19 21
    export "$1"="$REPLY"
20 22
fi

Also available in: Unified diff