1 if tty -s || [ "${0:0:1}" = "-" -o "$1" = "force" ]; then
2 # Remember if nocaseglob was on.
5 # Turn it off so we source stuff in the right order.
7 # Remember if nullglob was on.
10 # Turn it on so we can look in subdirectories.
15 # Turn it off to set case-sensitive matching
18 # Force these to come before everything else.
23 # Remember PATH so we can mangle it to find tsort and sed.
25 PATH=/usr/bin:/bin:/usr/ccs/bin
27 # Sort all scripts by dependencies.
28 profile_d=${PROFILE_HOME:-~}/.profile.d
31 for i in $profile_d/{*/,}*.bashrc; do
32 dep=$(sed -n 's/^##*[ ]*profile-required:[ ]*//p' "$i")
34 if [ -n "$dep" ]; then
47 # Avoid odd number of tokens for tsort.
48 n=$(echo "$deps" | wc -w)
49 if [ $((n%2)) = 1 ]; then
54 sorted=$(echo "$deps" | tsort)
55 if [ -n "$sorted" ]; then
65 # Source them all in the right order.
68 [ -e "$profile_d/$i" ] || continue
69 [ "${sourced/ $i /}" = "$sourced" ] || continue
71 sourced="$sourced $i "
74 # Maybe turn nocaseglob back on.
75 [ $nocg = 0 ] && shopt -s nocaseglob
76 # Maybe turn nullglob back off.
77 [ $nullglob = 0 ] || shopt -u nullglob
82 unset i d n dep deps profile_d path required unsorted sourced
83 unset lc_all nullglob nocg
85 # Don't inherit failure from the last script.