summaryrefslogtreecommitdiffstats
path: root/test/config/bashrc
blob: dcb8aacc53cccc6e328e9b3df1a718f973b8e14c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# bashrc file for bash-completion test suite

# Note that we do some initialization that would be too late to do here in
# conftest.py.

# Use emacs key bindings
set -o emacs

# Use bash strict mode
set -o posix

# Raise error on uninitialized variables
set -o nounset

# Unset `command_not_found_handle' as defined on Debian/Ubuntu, because this
# troubles and slows down testing
unset -f command_not_found_handle

TESTDIR=$(pwd)

export PS2='> '

# Also test completions of system administrator commands, which are
# installed via the same PATH expansion in `bash_completion.have()'
export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin

# ...as well as games on some systems not in PATH by default:
export PATH=$PATH:/usr/games:/usr/local/games

# For clean test state, avoid sourcing user's ~/.bash_completion
export BASH_COMPLETION_USER_FILE=/dev/null

# ...and avoid stuff in BASH_COMPLETION_USER_DIR and system install locations
# overriding in-tree completions. Setting the user dir would otherwise suffice,
# but simple xspec completions are only installed if a separate one is not
# found in *any* completion dirs, and we want to use our "shadow" completion
# dir with which we cause loading of our in-tree fallback completions
# instead of possibly (system-)installed upstream ones.
export BASH_COMPLETION_USER_DIR="$SRCDIRABS/fallback"
export BASH_COMPLETION_COMPAT_DIR="$SRCDIRABS/../bash_completion.d"
export XDG_DATA_DIRS=/var/empty

# Make sure default settings are in effect
unset -v \
    BASH_COMPLETION_CMD_CONFIGURE_HINTS \
    BASH_COMPLETION_CMD_CVS_REMOTE \
    BASH_COMPLETION_CMD_IWCONFIG_SCAN \
    BASH_COMPLETION_CMD_TAR_INTERNAL_PATHS \
    BASH_COMPLETION_COMPAT_IGNORE \
    BASH_COMPLETION_FILEDIR_FALLBACK \
    BASH_COMPLETION_KNOWN_HOSTS_WITH_HOSTFILE \
    COMP_CONFIGURE_HINTS \
    COMP_CVS_REMOTE \
    COMP_FILEDIR_FALLBACK \
    COMP_IWLIST_SCAN \
    COMP_KNOWN_HOSTS_WITH_HOSTFILE \
    COMP_TAR_INTERNAL_PATHS

# @param $1  Char to add to $COMP_WORDBREAKS
add_comp_wordbreak_char()
{
    [[ "${COMP_WORDBREAKS//[^$1]/}" ]] || COMP_WORDBREAKS+=$1
}

_comp__test_get_env()
{
    (
        # Do not output the state of test variables "_comp__test_+([0-9])_*"
        # and internal mutable variables "_comp_*_mut_*".
        local IFS=$' \t\n'
        # shellcheck disable=SC2046
        unset -v $(compgen -W '"${!_comp_@}"' -X '!_comp_@(_test_+([0-9])_*|*_mut_*)')
        _comp_unlocal IFS

        set -o posix
        set
    )
    declare -F
    shopt -p
    set -o
}

# Local variables:
# mode: shell-script
# End:
# ex: filetype=sh