1 if [ -t 0 -o "${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 for j in $profile_d/{,*/}$i; do
69 [ -e "$j" ] || continue
71 [ "${sourced/ $k /}" = "$sourced" ] || continue
73 sourced="$sourced $k "
78 # Maybe turn nocaseglob back on.
79 [ $nocg = 0 ] && shopt -s nocaseglob
80 # Maybe turn nullglob back off.
81 [ $nullglob = 0 ] || shopt -u nullglob
86 unset i j k d n dep deps profile_d path required unsorted sourced
87 unset lc_all nullglob nocg
89 # Don't inherit failure from the last script.