Implement the "wait" checkpoint action.
[tar.git] / scripts / tarcat
blob891843f9fd4c8a3eb7cc1e7ceba25c0bd1990fb0
1 #! /bin/sh
2 # Usage: tarcat volume1 volume2 ...
3 # concatenates a GNU tar multi-volume archive into a single tar archive.
4 # Author: Bruno Haible <bruno@clisp.org>, Sergey Poznyakoff <gray@gnu.org.ua>
6 # Copyright 2004-2005, 2010, 2013-2014, 2016-2017 Free Software
7 # Foundation, Inc.
9 # This file is part of GNU tar.
11 # GNU tar is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 3 of the License, or
14 # (at your option) any later version.
16 # GNU tar is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 # dump_type FILE [N]
25 # Print type character from block N (default 0) of tar archive FILE
26 dump_type() {
27 dd if="$1" skip=${2:-0} bs=512 count=1 2>/dev/null |
28 tr '\0' ' ' |
29 cut -c157
32 case `dump_type "$1"` in
33 [gx]) PAX=1;;
34 esac
36 cat "$1"
37 shift
38 for f
40 SKIP=0
41 T=`dump_type "$f"`
42 if [ -n "$PAX" ]; then
43 if [ "$T" = "g" ]; then
44 # Global extended header.... 2 blocks
45 # Extended header........... 2 blocks
46 # Ustar header.............. 1 block
47 # FIXME: This calculation is will fail for very long file names.
48 SKIP=5
50 else
51 if [ "$T" = "V" ]; then
52 T=`dump_type "$f" 1`
54 if [ "$T" = "M" ]; then
55 SKIP=$(($SKIP + 1))
58 dd skip=$SKIP if="$f"
59 done