4 # arc2tarz: convert arced file to tarred, compressed form.
5 # @(#) arc2tarz.ksh 1.0 92/02/16
6 # 91/03/28 john h. dubois iii (john@armory.com)
7 # 92/02/16 added -h option for help
9 # conversion to bash v2 syntax by Chet Ramey
12 Usage
="Usage: $0 arcfile [-hcg] [ tarzfile ]"
17 arcfile is the name of an arc file to convert to tarred, compressed form.
18 The file must have a .arc extension, but only the base name needs to be
19 given. If no output file name is given, it will be created in the current
20 directory with the name being the arcfile basename followed by .tar.EXT.
21 If the -c option is given, compress will be used, and EXT will be Z.
22 The default (also available with -g) is to use gzip, in which case EXT
23 is gz. If the basename is too long the extension may be truncated. All
24 uppercase letters in the names of files in the archive are moved to lowercase."
30 while getopts "hcg" opt
; do
33 c
) compress=compress; ext
=Z
;;
34 g
) compress=gzip ; ext
=gz
;;
35 *) echo "$Usage" 1>&2 ; exit 2;;
46 [ -z "$TMP" ] && tmpdir
=/tmp
/arc2tarz.$$ || tmpdir
=$TMP/arc2tarz.$$
53 if [ ! -f $arcfile ] ||
[ ! -r $arcfile ]; then
54 echo "Could not open arc file \"$arcfile\"."
60 *) arcfile
=$PWD/$arcfile ;;
63 basename=${arcfile%.arc}
64 basename=${basename##*/}
65 [ $# -lt 2 ] && tarzname
=$PWD/$basename.
tar.
$ext || tarzname
=$2
67 trap 'rm -rf $tmpdir $tarzname' 1 2 3 6 15
71 echo "unarcing files..."
76 new
=$
(echo $f |
tr A-Z a-z
)
77 if [ "$f" != "$new" ]; then
82 echo "tarring/compressing files..."
83 tar cf
- * |
$compress > $tarzname