Skip to content

Instantly share code, notes, and snippets.

@layus
Last active August 29, 2015 14:12
Show Gist options
  • Select an option

  • Save layus/64d9d2a0d6c051b86974 to your computer and use it in GitHub Desktop.

Select an option

Save layus/64d9d2a0d6c051b86974 to your computer and use it in GitHub Desktop.
A (INGInious) `run` file that works around missing tar and unzip binaries.
#!/bin/bash
extract () {
if [ -f $1 ] ; then
case $1 in
*.tgz)
# simulate missing tar command.
python -c "import tarfile; tarfile.open(\"$1\", 'r:gz').extractall(path=\"$2\");"
#tar xzf "$1" -C "$2"
;;
*.zip)
python -c "from zipfile import ZipFile; ZipFile(\"$1\", 'r').extractall(\"$2\");"
# unzip n'existe pas, mais zipfile est dans python...
# unzip "$1" -c "$2"
;;
*)
fail "'$1' cannot be extracted via extract()"
;;
esac
else
fail "'$1' is not a valid file"
fi
}
name=XXX
extract "$name" archive || fail "Impossible de décompresser le fichier $name"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment