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
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
# 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