Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

Commit

Permalink
Try to protect against paths with unusual characters
Browse files Browse the repository at this point in the history
  • Loading branch information
joelpurra committed Jul 25, 2014
1 parent 090d5aa commit 5c8dd62
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/domains/latest/all.sh
Expand Up @@ -3,15 +3,15 @@ set -e

domainroot="${1%/}"
domainroot="${domainroot:-$PWD}"
domainroot=$(cd "$domainroot"; echo "$PWD")
domainroot=$(cd -- "$domainroot"; echo "$PWD")

domainpaths=$(find "$domainroot" -type d ! -path "$domainroot")

for domainpath in $domainpaths;
do
# http://mywiki.wooledge.org/BashFAQ/020
# Bash
unset a i
while IFS= read -r -d '' domainpath; do
newest=$("${BASH_SOURCE%/*}/single.sh" "$domainpath")

if [[ -e "$newest" ]]; then
echo "$newest"
fi
done
done < <(find "$domainroot" -type d -print0 ! -path "$domainroot")
4 changes: 2 additions & 2 deletions src/domains/latest/single.sh
Expand Up @@ -3,9 +3,9 @@ set -e

domainpath="${1%/}"
domainpath="${domainpath:-$PWD}"
domainpath=$(cd "$domainpath"; echo "$PWD")
domainpath=$(cd -- "$domainpath"; echo "$PWD")

newest=$(find "$domainpath" -type f -name '*.har' | sort | tail -1)
newest=$(find "$domainpath" -type f -name '*.har' -print0 | sort -z | tail -1)

if [[ -e "$newest" ]]; then
echo "$newest"
Expand Down
2 changes: 1 addition & 1 deletion src/one-shot/data.sh
Expand Up @@ -3,7 +3,7 @@ set -e

domainroot="${1%/}"
domainroot="${domainroot:-$PWD}"
domainroot=$(cd "$domainroot"; echo "$PWD")
domainroot=$(cd -- "$domainroot"; echo "$PWD")

# Get a list of the most recently downloaded domains
"${BASH_SOURCE%/*}/../domains/latest/all.sh" "$domainroot" > "domains.latest.txt"
Expand Down

0 comments on commit 5c8dd62

Please sign in to comment.