From: Oleg Broytman Date: Mon, 16 Oct 2023 13:54:48 +0000 (+0300) Subject: .bashrc: Check the dir is not empty before looping over files X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=bf0ecd4cdb1fc128d756f65e9d1e6f5cf2202181;p=dotfiles.git .bashrc: Check the dir is not empty before looping over files --- diff --git a/.bashrc b/.bashrc index 18c00e2..fb36410 100644 --- a/.bashrc +++ b/.bashrc @@ -68,12 +68,14 @@ if [ -z "$BASH_COMPLETION_COMPAT_DIR" ]; then elif [ -r /etc/bash_completion ]; then _BASH_COMPLETIONS_DIR=/etc/bash_completion.d . /etc/bash_completion - elif [ -d /etc/bash_completion.d ]; then + elif [ -d /etc/bash_completion.d ] && + [ -n "`ls -A /etc/bash_completion.d`" ]; then _BASH_COMPLETIONS_DIR=/etc/bash_completion.d for _compf in /etc/bash_completion.d/*; do . $_compf done - elif [ -d /usr/local/etc/bash_completion.d ]; then + elif [ -d /usr/local/etc/bash_completion.d ] && + [ -n "`ls -A /usr/local/etc/bash_completion.d`" ]; then _BASH_COMPLETIONS_DIR=/usr/local/etc/bash_completion.d for _compf in /usr/local/etc/bash_completion.d/*; do . $_compf @@ -116,7 +118,8 @@ for cmd in unset; do ! has_completion $cmd && complete -A function -A variable $cmd done -if [ -d "$HOME"/.bash_completion.d ]; then +if [ -d "$HOME"/.bash_completion.d -a \ + -n "`ls -A $HOME/.bash_completion.d`" ]; then for _compf in "$HOME"/.bash_completion.d/*; do . $_compf done