gnu: gd: Fix failing test on i686.
[jackhill/guix/guix.git] / gnu / packages / patches / bash-completion-directories.patch
1 Bash-completion is written with FHS in mind where completion scripts
2 all get added to /usr/share/bash-completion/completions and are picked
3 up by the dynamic completion loader from there---whether they are
4 part of bash-completion or installed by another package.
5
6 On Guix systems, we want not only to search within bash-completion's own
7 directory, but also in the user's profile and in the system profile.
8 This is what this patch does.
9
10 --- bash-completion-2.1/bash_completion 2015-03-11 09:45:45.056846446 +0100
11 +++ bash-completion-2.1/bash_completion 2015-03-11 09:52:43.248159504 +0100
12 @@ -1928,9 +1928,20 @@ _completion_loader()
13 local compfile=./completions
14 [[ $BASH_SOURCE == */* ]] && compfile="${BASH_SOURCE%/*}/completions"
15 compfile+="/${1##*/}"
16 + local base="${1##*/}"
17
18 + # Look for completion files in the user and global profiles and
19 + # lastly in 'bash-completion' itself.
20 + for file in \
21 + "$HOME/.guix-profile/share/bash-completion/completions/$base" \
22 + "$HOME/.guix-profile/etc/bash_completion.d/$base" \
23 + "/run/current-system/profile/share/bash-completion/completions/$base" \
24 + "/run/current-system/profile/etc/bash_completion.d/$base" \
25 + "$compfile"
26 + do
27 # Avoid trying to source dirs; https://bugzilla.redhat.com/903540
28 - [[ -f "$compfile" ]] && . "$compfile" &>/dev/null && return 124
29 + [[ -f "$file" ]] && . "$file" &>/dev/null && return 124
30 + done
31
32 # Need to define *something*, otherwise there will be no completion at all.
33 complete -F _minimal "$1" && return 124