Skip to content

Enable using wget if curl is not installed #1

Description

@Chemaclass

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions