From 14062a6b6748241e84bae7fe2342ba5c81cc4e6b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 18 Aug 2016 11:20:17 +1200 Subject: Use consistent syntax for sh source loops --- bash/bash_profile | 11 ++++------- bash/bashrc | 3 +-- pdksh/pdkshrc | 3 +-- sh/profile | 7 +++---- sh/shrc | 7 +++---- 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/bash/bash_profile b/bash/bash_profile index 9d2fd76c..db1d9bc8 100644 --- a/bash/bash_profile +++ b/bash/bash_profile @@ -14,13 +14,10 @@ elif ((BASH_VERSINFO[0] == 2)) && fi # Load any supplementary scripts -if [[ -d $HOME/.bash_profile.d ]] ; then - for bash_profile in "$HOME"/.bash_profile.d/*.bash ; do - [[ -e $bash_profile ]] || continue - source "$bash_profile" - done - unset -v bash_profile -fi +for sh in "$HOME"/.bash_profile.d/*.bash ; do + [[ -e $sh ]] && source "$sh" +done +unset -v sh # If ~/.bashrc exists, source that too; the test for interactivity is in there if [[ -f $HOME/.bashrc ]] ; then diff --git a/bash/bashrc b/bash/bashrc index f36471f7..0e1859ad 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -111,7 +111,6 @@ fi for sh in "$ENV" \ "$HOME"/.bashrc.d/*.bash \ "$HOME"/.bash_completion.d/*.bash ; do - [[ -e $sh ]] || continue - source "$sh" + [[ -e $sh ]] && source "$sh" done unset -v sh diff --git a/pdksh/pdkshrc b/pdksh/pdkshrc index 46dbba2c..6039eea3 100644 --- a/pdksh/pdkshrc +++ b/pdksh/pdkshrc @@ -8,7 +8,6 @@ HISTSIZE=$((1 << 12)) # Load any supplementary scripts for pdkshrc in "$HOME"/.pdkshrc.d/*.pdksh ; do - [[ -e $pdkshrc ]] || continue - . "$pdkshrc" + [[ -e $pdkshrc ]] && . "$pdkshrc" done unset -v pdkshrc diff --git a/sh/profile b/sh/profile index aced40c2..5dfe0ef3 100644 --- a/sh/profile +++ b/sh/profile @@ -4,11 +4,10 @@ if [ -d "$HOME"/.local/bin ] ; then fi # Load all supplementary scripts in ~/.profile.d -for profile in "$HOME"/.profile.d/*.sh ; do - [ -e "$profile" ] || continue - . "$profile" +for sh in "$HOME"/.profile.d/*.sh ; do + [ -e "$sh" ] && . "$sh" done -unset -v profile +unset -v sh # If ENV is unset after running those scripts and ~/.shrc exists, set it as ENV if [ -z "$ENV" ] && [ -f "$HOME"/.shrc ] ; then diff --git a/sh/shrc b/sh/shrc index 3e657d4c..deb55cc2 100644 --- a/sh/shrc +++ b/sh/shrc @@ -6,8 +6,7 @@ esac # Load all the POSIX-compatible functions from ~/.shrc.d; more advanced shells # like bash will have their own functions -for shrc in "$HOME"/.shrc.d/*.sh ; do - [ -e "$shrc" ] || continue - . "$shrc" +for sh in "$HOME"/.shrc.d/*.sh ; do + [ -e "$sh" ] && . "$sh" done -unset -v shrc +unset -v sh -- cgit v1.2.3