File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,17 +23,17 @@ case "$name" in
2323esac
2424
2525extract_tar () {
26+ local tar_command=tar
2627 if command -v gtar > /dev/null 2>&1 ; then
27- gtar xf " $1 " --one-top-level=" $name "
28- return
28+ tar_command=gtar
2929 fi
3030
31- # BSD tar has no --one-top-level. Count distinct top-level entries so that
32- # archives with one root are extracted in place and multi-root archives are
33- # kept together under the archive name.
31+ # Count distinct top-level entries so that archives with one root are
32+ # extracted in place and multi-root archives are kept together under the
33+ # archive name.
3434 local top_level_count
3535 top_level_count=$(
36- tar tf " $1 " |
36+ " $tar_command " tf " $1 " |
3737 awk '
3838 {
3939 entry = $0
@@ -49,10 +49,14 @@ extract_tar() {
4949 )
5050
5151 if (( top_level_count > 1 )) ; then
52- mkdir -p " $name "
53- tar xf " $1 " -C " $name "
52+ if [[ $tar_command == gtar ]]; then
53+ " $tar_command " xf " $1 " --one-top-level=" $name "
54+ else
55+ mkdir -p " $name "
56+ " $tar_command " xf " $1 " -C " $name "
57+ fi
5458 else
55- tar xf " $1 "
59+ " $tar_command " xf " $1 "
5660 fi
5761}
5862
You can’t perform that action at this time.
0 commit comments