Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable using wget if curl is not installed #1

Open
Chemaclass opened this issue Oct 7, 2024 · 0 comments
Open

Enable using wget if curl is not installed #1

Chemaclass opened this issue Oct 7, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Chemaclass
Copy link
Owner

Status quo

Currently, curl is expected to be installed to be able to download an external script.

Expected

Consider checking if curl is not install, so we can use wget as fallback.

Example

Example used on bashunit:

# dependencies.sh : https://github.com/TypedDevs/bashunit/blob/main/src/dependencies.sh
function dependencies::has_curl() {
  command -v curl >/dev/null 2>&1
}

function dependencies::has_wget() {
  command -v wget >/dev/null 2>&1
}

# io.sh : https://github.com/TypedDevs/bashunit/blob/main/src/io.sh
function io::download_to() {
  local url="$1"
  local output="$2"
  if dependencies::has_curl; then
    curl -L -J -o "$output" "$url" 2>/dev/null
  elif dependencies::has_wget; then
    wget -q -O "$output" "$url" 2>/dev/null
  else
    return 1
  fi
}
@Chemaclass Chemaclass added the enhancement New feature or request label Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant