mirror of
http://git.davidovski.xyz/shblg.git
synced 2024-08-15 00:43:48 +00:00
Compare commits
No commits in common. "8ccb4fed2f82c8e924db9f6f7aa8f006a591965b" and "f8b8b0a7cad96c648c896fa6eb660fdb988dfdb2" have entirely different histories.
8ccb4fed2f
...
f8b8b0a7ca
1 changed files with 8 additions and 22 deletions
24
src/shblg.sh
24
src/shblg.sh
|
@ -8,13 +8,6 @@ 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)
|
||||||
|
@ -36,29 +29,22 @@ 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" ] && (
|
||||||
newer "$1" "$out_file" && (
|
|
||||||
# execute the file
|
# execute the file
|
||||||
cd $dirpath
|
cd "$dirpath"
|
||||||
printf "#!%s\n" "$path"
|
"$1" > "${out_file}"
|
||||||
"$1" > "$out_file"
|
|
||||||
)
|
|
||||||
return 0
|
return 0
|
||||||
} || {
|
) || {
|
||||||
newer "$1" "$out_file" && (
|
|
||||||
# just copy the file as is
|
# just copy the file as is
|
||||||
printf "%s\n" "$path"
|
|
||||||
cp "$1" "$out_file"
|
cp "$1" "$out_file"
|
||||||
)
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue