Do not leak local vars to shell

This commit is contained in:
crater2150 2020-04-29 10:35:23 +02:00
parent 054f3a8439
commit ec7266334e
2 changed files with 16 additions and 8 deletions

9
zshenv
View file

@ -1,7 +1,10 @@
export ZDOTDIR="${$(readlink $HOME/.zshenv):h:a}" export ZDOTDIR="${$(readlink $HOME/.zshenv):h:a}"
exists() { command -v "$@" >/dev/null } exists() { command -v "$@" >/dev/null }
for i in $ZDOTDIR/env/*.zsh; do function(){
. $i local i
done for i in $ZDOTDIR/env/*.zsh; do
. $i
done
}

15
zshrc
View file

@ -28,6 +28,7 @@ zdotfile() {
fi fi
} }
try-source() { try-source() {
local i=0
for i in "$@"; do for i in "$@"; do
if [[ -e "$i" ]]; then if [[ -e "$i" ]]; then
source $i source $i
@ -36,8 +37,9 @@ try-source() {
} }
exists() { command -v "$@" >/dev/null } exists() { command -v "$@" >/dev/null }
local dirfile=$(zdotfile dirs) function(){
try-source $dirfile try-source $(zdotfile dirs)
}
. $(zdotfile completion.zsh) . $(zdotfile completion.zsh)
@ -47,9 +49,12 @@ source $(zdotfile zplug.zsh)
stty -ixon stty -ixon
for i in ${ZDOTDIR:+$ZDOTDIR/aliases/*~*.zwc(N)} /etc/zsh/aliases/*~*.zwc(N); do function(){
. $i local i=0
done for i in ${ZDOTDIR:+$ZDOTDIR/aliases/*~*.zwc(N)} /etc/zsh/aliases/*~*.zwc(N); do
. $i
done
}
if ! (grep -q 'local' <<<$PATH && grep -q 'sbin' <<<$PATH); then if ! (grep -q 'local' <<<$PATH && grep -q 'sbin' <<<$PATH); then
. /etc/zsh/zprofile . /etc/zsh/zprofile