]> git.phdru.name Git - dotfiles.git/commitdiff
.bashrc: Check the dir is not empty before looping over files
authorOleg Broytman <phd@phdru.name>
Mon, 16 Oct 2023 13:54:48 +0000 (16:54 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 16 Oct 2023 14:36:37 +0000 (17:36 +0300)
.bashrc

diff --git a/.bashrc b/.bashrc
index 18c00e23b1d2d2f002e96beaf8b1753add70e61a..fb3641009418025cf8e95870087abcc46e00a5ea 100644 (file)
--- 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