mirror of http://git.davidovski.xyz/shblg.git
Compare commits
2 Commits
f8b8b0a7ca
...
8ccb4fed2f
Author | SHA1 | Date |
---|---|---|
davidovski | 8ccb4fed2f | |
davidovski | 14b7eb50d3 |
30
src/shblg.sh
30
src/shblg.sh
|
@ -8,6 +8,13 @@ usage () {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# check if a file has changed since last generating
|
||||||
|
#
|
||||||
|
newer () {
|
||||||
|
# TODO account for dependencies that have change
|
||||||
|
[ ! -e "$2" ] || [ "$1" -nt "$2" ]
|
||||||
|
}
|
||||||
|
|
||||||
while getopts ":o:i:h" opt; do
|
while getopts ":o:i:h" opt; do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
o)
|
o)
|
||||||
|
@ -29,22 +36,29 @@ process () {
|
||||||
dirpath="${1%"${1##*/}"}"
|
dirpath="${1%"${1##*/}"}"
|
||||||
out_file="${OUTPUT_DIR}${path}"
|
out_file="${OUTPUT_DIR}${path}"
|
||||||
|
|
||||||
printf "%s ...\n" "$path"
|
|
||||||
|
|
||||||
[ -d "$1" ] && {
|
[ -d "$1" ] && {
|
||||||
|
|
||||||
mkdir -p "$out_file"
|
mkdir -p "$out_file"
|
||||||
for f in "$1"/*; do
|
for f in "$1"/*; do
|
||||||
process "$f"
|
process "$f"
|
||||||
done
|
done
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
} || [ -x "$1" ] && (
|
} || [ -x "$1" ] && {
|
||||||
# execute the file
|
newer "$1" "$out_file" && (
|
||||||
cd "$dirpath"
|
# execute the file
|
||||||
"$1" > "${out_file}"
|
cd $dirpath
|
||||||
|
printf "#!%s\n" "$path"
|
||||||
|
"$1" > "$out_file"
|
||||||
|
)
|
||||||
return 0
|
return 0
|
||||||
) || {
|
} || {
|
||||||
# just copy the file as is
|
newer "$1" "$out_file" && (
|
||||||
cp "$1" "$out_file"
|
# just copy the file as is
|
||||||
|
printf "%s\n" "$path"
|
||||||
|
cp "$1" "$out_file"
|
||||||
|
)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue