From: Iain Patterson Date: Fri, 26 Feb 2010 09:27:16 +0000 (+0000) Subject: Look for .bashrc files in subdirectories. X-Git-Url: http://git.iain.cx/?p=profile.git;a=commitdiff_plain;h=7a9aad0d435f7afcc06fdbadb8764646a2c18cb6 Look for .bashrc files in subdirectories. --- diff --git a/.bash_profile b/.bash_profile index b10aba7..56a1eb0 100644 --- a/.bash_profile +++ b/.bash_profile @@ -4,6 +4,11 @@ if tty -s || [ "${0:0:1}" = "-" -o "$1" = "force" ]; then nocg=$? # Turn it off so we source stuff in the right order. shopt -u nocaseglob + # Remember if nullglob was on. + shopt -q nullglob + nullglob=$? + # Turn it on so we can look in subdirectories. + shopt -s nullglob # Remember LC_ALL. lc_all=$LC_ALL @@ -23,7 +28,7 @@ BECOME.bashrc" profile_d=${PROFILE_HOME:-~}/.profile.d deps= unsorted= - for i in $profile_d/*.bashrc; do + for i in $profile_d/{*/,}*.bashrc; do dep=$(sed -n 's/^##*[ ]*profile-required:[ ]*//p' "$i") i="${i##$profile_d/}" if [ -n "$dep" ]; then @@ -68,12 +73,14 @@ $deps" # Maybe turn nocaseglob back on. [ $nocg = 0 ] && shopt -s nocaseglob + # Maybe turn nullglob back off. + [ $nullglob = 0 ] || shopt -u nullglob # Reset LC_ALL. LC_ALL=$lc_all unset i d n dep deps profile_d path required unsorted sourced - unset lc_all nocg + unset lc_all nullglob nocg # Don't inherit failure from the last script. true