aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-04-03 20:24:44 -0300
committerEuAndreh <eu@euandre.org>2023-04-03 20:24:44 -0300
commitc10683660cf58ff420754ae730521be2d2666045 (patch)
tree08ba2e008c845af4efce86c0c802f08bf43efa73
parentbin/ifnew: Add new working utility (diff)
downloaddotfiles-c10683660cf58ff420754ae730521be2d2666045.tar.gz
dotfiles-c10683660cf58ff420754ae730521be2d2666045.tar.xz
bin/aux: Build repository db from filesystem instead of variable in the program
-rwxr-xr-xbin/aux53
1 files changed, 30 insertions, 23 deletions
diff --git a/bin/aux b/bin/aux
index b6509d3..50170c9 100755
--- a/bin/aux
+++ b/bin/aux
@@ -69,28 +69,35 @@ shift $((OPTIND - 1))
D="${XDG_DATA_HOME:-$HOME/.local/share}"/aux-repo
cp_all() {
- for f in "$@"; do
- mkdir -p "$(dirname "$f")"
- cp -v "$D/$f" "$f"
- done
+ from="$1"
+ to="$2"
+ mkdir -p "$(dirname "$to")"
+ echo "cp '$from' '$to'"
+ ifnew "$to" < "$from"
+ if [ -x "$from" ]; then
+ chmod +x "$to"
+ fi
+}
+
+cp_if() {
+ from="$1"
+ to="$2"
+ if [ -e "$to" ]; then
+ cp_all "$from" "$to"
+ fi
}
-FILES='
-aux/.gitignore
-aux/lib.sh
-aux/tld.txt
-aux/workflow/favicon.svg
-aux/workflow/head.html
-aux/workflow/md2html.sh
-aux/workflow/style.css
-aux/workflow/preamble.md.in
-aux/workflow/TODOs.sh
-aux/ci/report.sh
-'
-
-if [ $# = 0 ]; then
- # shellcheck disable=2086
- cp_all $FILES
-else
- cp_all "$@"
-fi
+cp_empty() {
+ from="$1"
+ to="$2"
+ if [ -e "$to" ] && [ ! -s "$to" ]; then
+ cp_all "$from" "$to"
+ fi
+}
+
+for d in "$D"/cases/*/; do
+ fn="$(basename "$d")"
+ find "$d" -not -type d | while read -r f; do
+ "$fn" "$f" "${f#"$D/cases/$fn/"}"
+ done
+done