The patch bash-completion-2.1-escape-characters.patch has unneeded tilde expansion. Every time 'quote_readline' is called, '~' will be expanded using the databases set in nsswitch.conf. If an external database like ldap is used and it is unavailable, this will freeze your shell. Solution: The tilde characters in the patch must be escaped - elif [[ $1 == ~* ]]; then + elif [[ $1 == \~* ]]; then # avoid escaping first ~ - printf -v $2 ~%q "${1:1}" + printf -v $2 \~%q "${1:1}" See also: * https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/1390061 * http://unix.stackexchange.com/a/185960 Reproducible: Always Steps to Reproduce: strace -e connect bash -c ". /usr/share/bash-completion/bash_completion; quote_readline '/var'; echo" Actual Results: If nscd *is not* running, something like: connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("XXX.XXX.XXX.XXX")}, 16) = 0 connect(3, {sa_family=AF_INET, sin_port=htons(389), sin_addr=inet_addr("XXX.XXX.XXX.XXX")}, 16) = -1 EINPROGRESS (Operation now in progress) If nscd *is* running, something like: connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = 0 connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = 0 Expected Results: There should be no connection syscall at all.
Thanks for the suggestion. However, before applying it I need to check if the tilde expansion discrepancy doesn't apply here. I recall that tilde expansion wasn't done in some old bash versions, and I need if that 'old' isn't 4.3.
Ok, it seems 4.3-clean.
commit 3c7ff5b0a5a073956e153ce8a3eb8e1d80a1d44d Author: Michał Górny <mgorny@gentoo.org> AuthorDate: Tue Nov 29 13:27:05 2016 Commit: Michał Górny <mgorny@gentoo.org> CommitDate: Tue Nov 29 13:37:01 2016 app-shells/bash-completion: Fix unquoted ~ in readline patch, #601194