diff options
author | Tom Willemse | 2022-06-18 20:56:33 -0700 |
---|---|---|
committer | Tom Willemse | 2022-06-18 20:56:33 -0700 |
commit | 565813b43ef351489bf1278679d45006e7c2634c (patch) | |
tree | 445af89d84a416303894917b6bf4e072b6b29851 | |
parent | bf6ee3888ba9e19f862e76dfb14fbe9cf56ad6c3 (diff) | |
download | update-mirrors-565813b43ef351489bf1278679d45006e7c2634c.tar.gz update-mirrors-565813b43ef351489bf1278679d45006e7c2634c.zip |
Don't write the mirrorlist if it can't be downloaded
Before if the ‘curl’ command failed, it wouldn't send any output to sed, which
would succeed, and that would go into the destination file.
Now we check the status explicitly before moving on and print a message when
‘curl’ fails.
-rwxr-xr-x | update-mirrors | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/update-mirrors b/update-mirrors index 7e9b68c..8cf158f 100755 --- a/update-mirrors +++ b/update-mirrors @@ -65,8 +65,14 @@ sudo." | fold >&2 fi # Download, ready, output -curl -s -L "$(make-url)" | sed 's/^#\([^#].*\)/\1/' > "$dest" -echo "Saved in ${dest}" +mirrorlist=$(curl -s -L "$(make-url)") + +if [[ $? -eq 0 ]]; then + echo "$mirrorlist" | sed 's/^#\([^#].*\)/\1/' > "$dest" + echo "Saved in ${dest}" +else + echo "Couldn't load mirrorlist, not updating." +fi if [[ -f "${dest}.pacnew" ]]; then rm "${dest}.pacnew" |