diff options
author | EuAndreh <eu@euandre.org> | 2023-04-03 20:24:44 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2023-04-03 20:24:44 -0300 |
commit | c10683660cf58ff420754ae730521be2d2666045 (patch) | |
tree | 08ba2e008c845af4efce86c0c802f08bf43efa73 | |
parent | bin/ifnew: Add new working utility (diff) | |
download | dotfiles-c10683660cf58ff420754ae730521be2d2666045.tar.gz dotfiles-c10683660cf58ff420754ae730521be2d2666045.tar.xz |
bin/aux: Build repository db from filesystem instead of variable in the program
-rwxr-xr-x | bin/aux | 53 |
1 files changed, 30 insertions, 23 deletions
@@ -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 |