aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-12-02 12:14:22 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-12-02 12:42:25 +1300
commitd0edad20fb5efc2dfc493345e1e7419c39a5558f (patch)
treeb8a8a8da3f8349b6679b83dac3f9a14678e5a407
parent1351b3f831a93f78665ee39c5a5b66d14a169d3d (diff)
downloaddotfiles-d0edad20fb5efc2dfc493345e1e7419c39a5558f.tar.gz
dotfiles-d0edad20fb5efc2dfc493345e1e7419c39a5558f.zip
Use consistent temp names for shell subfile vars
-rw-r--r--bash/bashrc8
-rw-r--r--bash/bashrc.d/completion.bash32
-rw-r--r--ksh/kshrc6
-rw-r--r--zsh/zshrc8
4 files changed, 36 insertions, 18 deletions
diff --git a/bash/bashrc b/bash/bashrc
index 3b4c91bd..a05526f2 100644
--- a/bash/bashrc
+++ b/bash/bashrc
@@ -95,8 +95,8 @@ if ((BASH_VERSINFO[0] >= 4)) ; then
fi
# Load Bash-specific startup files
-for sh in "$HOME"/.bashrc.d/*.bash ; do
- [[ -e $sh ]] || continue
- source "$sh"
+for bash in "$HOME"/.bashrc.d/*.bash ; do
+ [[ -e $bash ]] || continue
+ source "$bash"
done
-unset -v sh
+unset -v bash
diff --git a/bash/bashrc.d/completion.bash b/bash/bashrc.d/completion.bash
index ff3a95c1..5161a0bf 100644
--- a/bash/bashrc.d/completion.bash
+++ b/bash/bashrc.d/completion.bash
@@ -108,19 +108,37 @@ if ((BASH_VERSINFO[0] >= 4)) ; then
# Handler tries to load appropriate completion for commands
_completion_loader() {
- [[ -n $1 ]] || return
+
+ # Check completed command for validity
+ case $1 in
+ # Not empty
+ '') return 1 ;;
+ # Not starting with an underscore
+ _*) return 1 ;;
+ esac
+
+ # Build expected path for the command completion
local compspec
compspec=$HOME/.bash_completion.d/$1.bash
- [[ -f $compspec ]] || return
- source "$compspec" >/dev/null 2>&1 && return 124
+
+ # Skip directories and nonexistent files
+ [[ -e $compspec ]] || return
+ ! [[ -d $compspec ]] || return
+
+ # Try to read the file, return 124 if it worked
+ if source "$compspec" ; then
+ return 124
+ fi
}
+
+ # Set completion loader to use the above function
complete -D -F _completion_loader -o bashdefault -o default
# If not, load all of the completions up now
else
- for sh in "$HOME"/.bash_completion.d/*.bash ; do
- [[ -e $sh ]] || continue
- source "$sh"
+ for bash in "$HOME"/.bash_completion.d/[^_]*.bash ; do
+ [[ -e $bash ]] || continue
+ source "$bash"
done
- unset -v sh
+ unset -v bash
fi
diff --git a/ksh/kshrc b/ksh/kshrc
index 43ac14da..1aea4b9d 100644
--- a/ksh/kshrc
+++ b/ksh/kshrc
@@ -20,7 +20,7 @@ set -o trackall
HISTFILE=$HOME/.ksh_history
# Load any supplementary scripts
-for kshrc in "$HOME"/.kshrc.d/*.ksh ; do
- [[ -e $kshrc ]] && . "$kshrc"
+for ksh in "$HOME"/.kshrc.d/*.ksh ; do
+ [[ -e $ksh ]] && . "$ksh"
done
-unset -v kshrc
+unset -v ksh
diff --git a/zsh/zshrc b/zsh/zshrc
index 2977c4d9..0e111364 100644
--- a/zsh/zshrc
+++ b/zsh/zshrc
@@ -16,8 +16,8 @@ HISTFILE=$HOME/.zsh_history
SAVEHIST=$((1 << 12))
# Load Zsh-specific startup files
-for sh in "$HOME"/.zshrc.d/*.zsh ; do
- [[ -e $sh ]] || continue
- source "$sh"
+for zsh in "$HOME"/.zshrc.d/*.zsh ; do
+ [[ -e $zsh ]] || continue
+ source "$zsh"
done
-unset -v sh
+unset -v zsh