Fix typo in license headers
[oweals/cde.git] / cde / programs / dtksh / ksh93 / src / cmd / pax / tar.sh
1 # $XConsortium: tar.sh /main/2 1995/07/19 17:13:19 drk $
2 :
3 # Glenn Fowler
4 # AT&T Bell Laboratories
5 # @(#)tar.sh (gsf@research.att.com) 04/06/89
6 #
7 # tar -> pax interface script
8 #
9
10 command=tar
11 usage="
12 Usage: $command c[vwfbB[[0-9][hlm]]] [pathname ...]
13        $command r[vwfbB[[0-9][hlm]]] [files ...]
14        $command t[vwfbB[[0-9][hlm]]
15        $command u[vwfbB[[0-9][hlm]]] [pathname ...]
16        $command x[vwfblmB[[0-9][hlm]]] [pathname ...]"
17
18 case $1 in
19 *[tx]*)         mode="-r" ;;
20 *[cru]*)        mode="-w" ;;
21 *)              echo "$command: one of crtux must be specified$usage" >&2; exit 1 ;;
22 esac
23 options="-P"
24 file="-t 0"
25 list=""
26 r_ok="1"
27 w_ok="1"
28 arg=$1
29 lastopt=""
30 shift
31 for opt in `echo '' $arg | sed -e 's/^ -//' -e 's/./& /g'`
32 do      case $opt in
33         [0-9])  file="-t $opt" ;;
34         [hlm])  case $lastopt in
35                 [0-9])  file="${file}$opt" ;;
36                 *)      case $opt in
37                         h)      options="$options -L" ;;
38                         l)      ;;
39                         m)      r_ok="" options="$options -$opt" ;;
40                         esac
41                         ;;
42                 esac
43                 ;;
44         [v])    options="$options -$opt" ;;
45         b)      case $# in
46                 0)      echo "$command: blocking factor argument expected$usage" >&2; exit 1 ;;
47                 esac
48                 options="$options -b ${1}b"
49                 shift
50                 ;;
51         c)      r_ok="" ;;
52         f)      case $# in
53                 0)      echo "$command: file name argument expected$usage" >&2; exit 1 ;;
54                 esac
55                 case $1 in
56                 -)      file="" ;;
57                 *)      file="-f $1" ;;
58                 esac
59                 shift
60                 ;;
61         r)      r_ok="" options="$options -a" ;;
62         t)      w_ok="" list="1" ;;
63         u)      r_ok="" options="$options -u" ;;
64         w)      options="$options -y" ;;
65         x)      w_ok="" ;;
66         B)      options="$options -b 10k" ;;
67         *)      echo "$command: invalid option -$opt$usage" >&2; exit 1 ;;
68         esac
69         lastopt=$opt
70 done
71 case $mode in
72 -r)     case $r_ok in
73         "")     echo "$command: options inconsistent with archive read" >&2; exit 1 ;;
74         esac
75         ;;
76 -w)     case $w_ok in
77         "")     echo "$command: options inconsistent with archive write" >&2; exit 1 ;;
78         esac
79         case $# in
80         0)      set - "." ;;
81         esac
82         options="$options -x tar"
83         ;;
84 esac
85 case $list in
86 "1")    mode="" ;;
87 esac
88 pax $mode $options $file "$@"