Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
blackboard-extractor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Richard Torenvliet
blackboard-extractor
Commits
11daf05e
Commit
11daf05e
authored
Sep 20, 2015
by
Richard Torenvliet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add auto functionality of tar for the default unpacking strategy
parent
a3f71be1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
15 deletions
+19
-15
bb_extract
bb_extract
+19
-15
No files found.
bb_extract
View file @
11daf05e
...
@@ -34,28 +34,32 @@ NORM=`tput sgr0`
...
@@ -34,28 +34,32 @@ NORM=`tput sgr0`
BOLD=`tput bold`
BOLD=`tput bold`
REV=`tput smso`
REV=`tput smso`
unpack_result=""
# using auto compression detection of tar. This is different for
# GNU and bsdtar, hence this check
if tar --version | grep -q GNU; then
auto_unpack_tar_command="tar -xaf";
else
auto_unpack_tar_command="tar -xf";
fi
function extract() {
function extract() {
ARCHIVE=$1
ARCHIVE=`printf "%q" $1`
OUTPUT=$2
OUTPUT=`printf "%q" $2`
result="success"
unpack_result="success"
default_unpack_command="$auto_unpack_tar_command ARCHIVE $OUTPUT"
if [ -f $ARCHIVE ] ; then
if [ -f $ARCHIVE ] ; then
case $ARCHIVE in
case $ARCHIVE in
*.tbz) tar xjf $ARCHIVE -C $OUTPUT;;
*.bz2) tar xjf $ARCHIVE -C $OUTPUT;;
*.gz) tar xzf $ARCHIVE -C $OUTPUT;;
*.tgz) tar xzf $ARCHIVE -C $OUTPUT;;
*.tbz2) tar xjf $ARCHIVE -C $OUTPUT;;
*.rar) unrar x $ARCHIVE $OUTPUT;;
*.rar) unrar x $ARCHIVE $OUTPUT;;
*.tar) tar xf $ARCHIVE -C $OUTPUT;;
*.zip) unzip $ARCHIVE -d $OUTPUT 1> /dev/null;;
*.zip) unzip $ARCHIVE -d $OUTPUT 1> /dev/null;;
*)
$result="fail"
*)
bash -c $default_unpack_command;;
esac
esac
else
else
$result="file_not_found
"
unpack_result="fail
"
fi
fi
echo $result
}
}
# forloop delimiter
# forloop delimiter
...
@@ -161,9 +165,9 @@ while [ $# -ne 0 ]; do
...
@@ -161,9 +165,9 @@ while [ $# -ne 0 ]; do
create_directory $OUTPUT_DIR
create_directory $OUTPUT_DIR
echo "extracting $ZIPFILE to $BB_EXTRACT_DIR"
echo "extracting $ZIPFILE to $BB_EXTRACT_DIR"
result=$(extract $ZIPFILE $BB_EXTRACT_DIR)
extract $ZIPFILE $BB_EXTRACT_DIR
if [ $result != "fail" ]; then
if [ $
unpack_
result != "fail" ]; then
echo "find and unpack all submitted assignments"
echo "find and unpack all submitted assignments"
find_and_unpack $BB_EXTRACT_DIR $OUTPUT_DIR
find_and_unpack $BB_EXTRACT_DIR $OUTPUT_DIR
else
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment