-
-
Save layus/64d9d2a0d6c051b86974 to your computer and use it in GitHub Desktop.
A (INGInious) `run` file that works around missing tar and unzip binaries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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