Environment


[ 1 About ] [ 2 Code Snippets ]

About

Introspecting and manipulating the shell environment

Code Snippets

if [[ ${var+x} ]]; then # var is set but it could be empty if [[ ! ${var+x} ]]; then # var is not set if [[ ${var+x} && ! $var ]]; then # var is set and is empty # Alternatively if [[ -v var ]]; then # var is set but it could be empty if [[ ! -v var ]]; then # var is not set if [[ -v var && ! $var ]]; then # var is set and is empty if [[ -v var && -z $var ]]; then # var is set and is empty
# works most reliably SRC_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
[[ "${BASH_SOURCE[0]}" != "${0}" ]] && SOURCED=1 if [ -z "$SOURCED" ]; then pretty_error "This script needs to be sourced, i.e. source './virtualenv.bash', not './virtualenv.bash'" exit 1 fi