From c10683660cf58ff420754ae730521be2d2666045 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Mon, 3 Apr 2023 20:24:44 -0300 Subject: bin/aux: Build repository db from filesystem instead of variable in the program --- bin/aux | 53 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 23 deletions(-) (limited to 'bin') 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 -- cgit v1.2.3