hypriot / flash

Command line script to flash SD card images of any kind
MIT License
1.01k stars 173 forks source link

fail early when url is malformed or the server return an error code #99

Closed erickeller closed 7 years ago

erickeller commented 7 years ago

When a user provided a malformed url or the server return a file "Not Found" error, the script continued to execute. the --fail option passed to curl prevent this behavior and result in a proper error handling.

have a look at the following example:

./flash --hostname node01 https://github.com/hypriot/image-builder-rpi/releases/download/v1.4.0/hypriotos-rpi-v1.4.0.im
/usr/bin/curl
Downloading https://github.com/hypriot/image-builder-rpi/releases/download/v1.4.0/hypriotos-rpi-v1.4.0.im ...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404 Not Found
StefanScherer commented 7 years ago

Good idea, thanks @erickeller. LGTM