Guest User

Untitled

a guest
Oct 20th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.08 KB | None | 0 0
  1. download_file() {
  2.     # Download a file with the preferred downloader
  3.     # first arg $1 is the URL
  4.     # second arg $2 is the output file
  5.     if [[ $downloader =~ .+wget$ ]]
  6.     then
  7.         # wget
  8.         if "$downloader -c -O $2 -- $1"
  9.         then
  10.             return 0
  11.         else
  12.             return 1
  13.         fi  
  14.     else # we can just else instead of elif since we know we have curl
  15.         # curl
  16.         if "$downloader -L $1 -o $2"
  17.         then
  18.             return 0
  19.         else
  20.             return 1
  21.         fi  
  22.     fi  
  23. }
  24.  
  25. download_file_simple() {
  26.     # Download a file with the preferred downloader
  27.     # first arg $1 is the URL
  28.     # second arg $2 is the output file
  29.     if [[ $downloader =~ .+wget$ ]]
  30.     then
  31.         # wget
  32.         if "$downloader -c -- $1"
  33.         then
  34.             return 0
  35.         else
  36.             return 1
  37.         fi  
  38.     else # we can just else instead of elif since we know we have curl
  39.         # curl
  40.         if "$downloader -L $1"
  41.         then
  42.             return 0
  43.         else
  44.             return 1
  45.         fi  
  46.     fi  
  47. }
Add Comment
Please, Sign In to add comment