2016-10-04 08:38:41 -04:00
|
|
|
#!/usr/bin/env zsh
|
2017-04-13 11:26:30 -04:00
|
|
|
|
2016-10-04 08:38:41 -04:00
|
|
|
actualSize=$(wc -c < $1)
|
2017-04-13 11:26:30 -04:00
|
|
|
testDir=$TMPDIR/dots-partial-dl-test-$UID-$$
|
|
|
|
if [[ -d $testDir ]]; then
|
|
|
|
echo "$testDir exists, is this test already running?" >&2
|
|
|
|
echo "Refusing to launch. Remove $testDir manually if necessary." >&2
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
|
|
|
repeat-char() {
|
|
|
|
local char=$1
|
|
|
|
local -i count=$2
|
|
|
|
(( count )) && printf "$char%.0s" {1..$count}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (( size = 0; size < actualSize - 1; size++ )); do
|
|
|
|
percent=$(( size * 100 / actualSize ))
|
|
|
|
progress=$(( percent / 10 ))
|
|
|
|
printf " [%-10s] [%${#actualSize}d/%d]\r" "$(repeat-char = $progress)" $size $actualSize >&2
|
2016-10-04 08:38:41 -04:00
|
|
|
|
2017-04-13 11:26:30 -04:00
|
|
|
head -c$size $1 | env -i HOME=$testDir zsh 2>/dev/null
|
|
|
|
if [[ -d $testDir ]]; then
|
|
|
|
rm -rf $testDir
|
|
|
|
printf "\ndots still ran with only %d bytes available, %d%% of its full %d bytes!\n" $size $percent $actualSize >&2
|
2016-10-04 08:38:41 -04:00
|
|
|
exit $size
|
|
|
|
fi
|
|
|
|
done
|