self-update: better network error handling; fix #580

A power outage could corrupt a `fisher self-update`. 
This change prevents fisher from overwriting itself to death.
This commit is contained in:
Guilherme Silva 2020-07-27 08:16:49 -03:00 committed by GitHub
parent 994506e594
commit 510e6254ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -157,7 +157,7 @@ function _fisher_self_update -a file
echo "fetching $url" >&2
command curl -s "$url?nocache" >$file.
set -l next_version (command awk '{ print $4 } { exit }' <$file.)
set -l next_version (command awk '$4 ~ /^[0-9]+\.[0-9]+\.[0-9]+$/ { print v=$4 } { exit !v }' <$file.)
switch "$next_version"
case "" $fisher_version
command rm -f $file.