File: zfile

package info (click to toggle)
gzip 1.6-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,068 kB
  • ctags: 4,221
  • sloc: ansic: 32,146; sh: 8,072; makefile: 334; perl: 11
file content (28 lines) | stat: -rwxr-xr-x 584 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh

if test $# = 0; then
  echo 'zfile: file(1) for programs which may be compressed with gzexe'
  echo usage: `basename $0`  files...
  exit 1
fi

tmp=/tmp/gz$$

for i do
  if test ! -f "$i" ; then
    echo `basename $0`: $i not a file
    res=1
    continue
  fi
  skip=18
  if sed -e 1d -e 2q "$i" | grep "^skip=[0-9]*$" >/dev/null; then
    eval `sed -e 1d -e 2q "$i"`
  fi
  if tail +$skip "$i" | gzip --list >/dev/null 2>&1; then
    tail +$skip "$i" | gzip -cd | dd count=1 >$tmp 2>/dev/null
    file $tmp | sed "s|^$tmp|$i|"
  else
    file "$i"
  fi
  rm -f $tmp
done