Skip to content

_install doesn't handle download failure #23

@quinnyo

Description

@quinnyo

The _install function will fail pretty messily in case of a number of errors, but particularly in case of the download failing.

rgbenv/rgbenv

Lines 334 to 346 in 2515774

curl -L "$download_link" > "$tempfile"
dirname=$(tar tzf "$tempfile" | head -1 | cut -f1 -d'/')
cd "$RGBENV_VERSIONS"
tar xzf "$tempfile"
mv "$RGBENV_VERSIONS/$dirname" "$RGBENV_VERSIONS/$RGBDS_PREFIX$version"
trap - ERR
rm -f "${tempfile}"
# then build it
echo "Building RGBDS $version..."
cd "$RGBENV_VERSIONS/$RGBDS_PREFIX$version"
if make; then

if $tempfile is not a valid tarball, i.e. if the download fails:

  • tar -t will fail
  • $dirname will be empty, ideally
  • tar -x will fail
  • mv will fail, trying to move the versions directory into itself
  • cd will fail
  • make will be invoked in the version directory, probably "no makefile found" error
  • a message will be printed saying that "You may still use this version, just with missing tools."

The most basic thing to add would be checking tar's exit status, which would catch a lot of potential problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions