Last active
August 29, 2015 14:10
-
-
Save psmay/b90849fe7752006e897c to your computer and use it in GitHub Desktop.
Get a list of scripts in a dir and allow them to order themselves using a "#require " line stating deps.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BASHRC_D=~/.bashrc.d | |
schedule() | |
{ | |
( | |
while [ $# -gt 0 ]; do | |
local name="$1" | |
( | |
case "$name" in | |
*.sh | .* | __* ) | |
# Skip | |
;; | |
*) | |
if [ -f "$name" -a -r "$name" ] ; then | |
sed '/^#require\s/!d; s/^#require\s//; s/\s\+/\n/g;' <"$name" | |
echo "$name" | |
fi | |
;; | |
esac | |
) | awk -v name="$name" '{ print name " " $0 }' | |
shift | |
done | |
) | tsort | tac | |
} | |
(cd "$BASHRC_D"; schedule *) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment