Compare commits
No commits in common. "f379471a5fac58dc74dae45355c6bbc39766f4ea" and "dc3d59b4a467bddd8b8d8781384032f06b529fd4" have entirely different histories.
f379471a5f
...
dc3d59b4a4
2 changed files with 15 additions and 53 deletions
|
@ -82,7 +82,7 @@ fetch() {
|
||||||
(( $#packages == 0 )) && packages=( $DOTFILES/*(N:t) )
|
(( $#packages == 0 )) && packages=( $DOTFILES/*(N:t) )
|
||||||
for p in $packages; do
|
for p in $packages; do
|
||||||
cd $DOTFILES/$p
|
cd $DOTFILES/$p
|
||||||
git fetch -p || return $?
|
git fetch -p
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ pull() {
|
||||||
(( $#packages == 0 )) && packages=( $DOTFILES/*(N:t) )
|
(( $#packages == 0 )) && packages=( $DOTFILES/*(N:t) )
|
||||||
for p in $packages; do
|
for p in $packages; do
|
||||||
cd $DOTFILES/$p
|
cd $DOTFILES/$p
|
||||||
git pull || return $?
|
git pull
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,9 +157,8 @@ main() {
|
||||||
link) link ${argv[2,-1]} ;;
|
link) link ${argv[2,-1]} ;;
|
||||||
pull) pull ${argv[2,-1]} ;;
|
pull) pull ${argv[2,-1]} ;;
|
||||||
st|status) status ${argv[2,-1]} ;;
|
st|status) status ${argv[2,-1]} ;;
|
||||||
*) echo "Unknown subcommand $comm" >&2; return 2 ;;
|
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
}
|
} # Wrap the entire program in a braced block so it won't run at all if you do curl | zsh and the connection drops.
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
script=$1
|
actualSize=$(wc -c < $1)
|
||||||
actualSize=$(wc -c < $script)
|
|
||||||
testDir=$TMPDIR/dots-partial-dl-test-$UID-$$
|
testDir=$TMPDIR/dots-partial-dl-test-$UID-$$
|
||||||
if [[ -d $testDir ]]; then
|
if [[ -d $testDir ]]; then
|
||||||
echo "$testDir exists, is this test already running?" >&2
|
echo "$testDir exists, is this test already running?" >&2
|
||||||
|
@ -15,51 +14,15 @@ repeat-char() {
|
||||||
(( count )) && printf "$char%.0s" {1..$count}
|
(( count )) && printf "$char%.0s" {1..$count}
|
||||||
}
|
}
|
||||||
|
|
||||||
partial-dl-test() {
|
|
||||||
local -i showProgress=0 size=0 STATUS=0
|
|
||||||
local -F percent=0 progress=0
|
|
||||||
local OUT=''
|
|
||||||
mkdir $testDir
|
|
||||||
|
|
||||||
# We run the test for every partial filesize up to the actual size - 2,
|
|
||||||
# because we expect the script to work properly when the entirety has been
|
|
||||||
# downloaded, and it'll also work properly if just the last byte is missing
|
|
||||||
# because that last byte is a newline.
|
|
||||||
for (( size = 0; size < actualSize - 1; size++ )); do
|
for (( size = 0; size < actualSize - 1; size++ )); do
|
||||||
percent=$(( size * 100.0 / actualSize ))
|
percent=$(( size * 100 / actualSize ))
|
||||||
progress=$(( percent / 10 ))
|
progress=$(( percent / 10 ))
|
||||||
(( showProgress++ % 100 == 0 || size == actualSize - 2 )) && printf " [%-10s] [%${#actualSize}d/%d]\r" "$(repeat-char = $progress)" $size $actualSize >&2
|
printf " [%-10s] [%${#actualSize}d/%d]\r" "$(repeat-char = $progress)" $size $actualSize >&2
|
||||||
|
|
||||||
OUT=$(head -c$size $script | env -i HOME=$testDir/home zsh 2>&1)
|
head -c$size $1 | env -i HOME=$testDir zsh 2>/dev/null
|
||||||
STATUS=$?
|
if [[ -d $testDir ]]; then
|
||||||
|
rm -rf $testDir
|
||||||
if (( STATUS == 0 )); then
|
printf "\ndots still ran with only %d bytes available, %d%% of its full %d bytes!\n" $size $percent $actualSize >&2
|
||||||
# If zsh silently did nothing, that's fine.
|
exit $size
|
||||||
[[ -z $OUT ]] && continue
|
|
||||||
# If zsh non-silently reported a success, that's not fine.
|
|
||||||
print "dots reported a success with only $size bytes available, producing this output:${(qq)OUT}" >&2
|
|
||||||
return $size
|
|
||||||
fi
|
|
||||||
|
|
||||||
# There are a few error messages we can get from zsh that we expect to see when doing this kind of test.
|
|
||||||
if ! [[ $OUT = 'zsh: parse error'* ||
|
|
||||||
$OUT = 'zsh: unmatched '* ||
|
|
||||||
$OUT = 'zsh: closing brace expected' ||
|
|
||||||
$OUT = 'zsh: condition expected: '* ]]; then
|
|
||||||
print "dots produced unexpected output with only $size bytes available and status $STATUS: ${(qq)OUT}" >&2
|
|
||||||
return $size
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -d $testDir/home ]]; then
|
|
||||||
print "dots bootstrapped itself with only $size bytes available, $percent% of its full $actualSize bytes!" >&2
|
|
||||||
return $size
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
print "dots safely did nothing for partially downloaded sizes up to $((size-1))/$actualSize bytes!" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
partial-dl-test
|
|
||||||
} always {
|
|
||||||
rm -rf $testDir
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue