Project

General

Profile

« Previous | Next » 

Revision 1950

env_password: Use ${BASH_SOURCE0} for $self and $self for $0. return instead of exit on usage error in case user is running it from a shell.

View differences:

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

  
4
self="$(readlink -f -- "$BASH_SOURCE")"
4
self="$(readlink -f -- "${BASH_SOURCE[0]}")"
5 5

  
6 6
set -o pipefail
7 7

  
8
test "${BASH_LINENO[0]}" = 0 && missing_dot=true || missing_dot=false
9
    # whether run without initial "."
10

  
11 8
store=
12 9
test "$1" = - && { store=1; shift;}
13 10

  
14
if $missing_dot || ! test "$#" -ge 1; then
15
    $missing_dot && self="$0"
11
# Was run without initial ".", or with insufficient parameters
12
if test "${BASH_LINENO[0]}" = 0 -o "$#" -lt 1; then
16 13
    echo "Usage: . $self env_var [desc] (note initial \".\")"|fold -s >&2
17
    exit 2
14
    return 2
18 15
fi
19 16

  
20 17
desc="$2"

Also available in: Unified diff