Skip to content

Commit bca0396

Browse files
committed
refactor: ensure targets exist before downloading
Signed-off-by: Lucas Larson <LucasLarson@riseup.net>
1 parent b6c2160 commit bca0396

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

custom/aliases.sh

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9634,18 +9634,21 @@ wget_download() {
96349634
-e 's/www\.//' \
96359635
-e 's/[:/].*//'
96369636
)"
9637-
# check that there is just
9638-
# 1 unique file serial number amongst the
9639-
# 2 targets
9640-
test "$(
9641-
find -- \
9642-
"${HOME%/}"'/Code/'"${1-}"'/.https' \
9643-
"${HOME%/}"'/Sites/'"${1-}" \
9644-
-prune \
9645-
-exec ls -1 -d -i -L -- {} + |
9646-
awk -- '! seen[$1]++ {print $1}' |
9647-
grep -c -e '.'
9648-
)" -eq 1 ||
9637+
# check both targets exist
9638+
test -d "${HOME%/}"'/Code/'"${1-}"'/.https' &&
9639+
test -d "${HOME%/}"'/Sites/'"${1-}" &&
9640+
# check that there is just
9641+
# 1 unique file serial number amongst the
9642+
# 2 targets
9643+
test "$(
9644+
find -- \
9645+
"${HOME%/}"'/Code/'"${1-}"'/.https' \
9646+
"${HOME%/}"'/Sites/'"${1-}" \
9647+
-prune \
9648+
-exec ls -1 -d -i -L -- {} + |
9649+
awk -- '! seen[$1]++ {print $1}' |
9650+
grep -c -e '.'
9651+
)" -eq 1 ||
96499652
# or we fail
96509653
return 11
96519654

0 commit comments

Comments
 (0)