home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 8 / CDASC08.ISO / VRAC / GNUZIP_.ZIP / GZEXE.IN (.txt) < prev    next >
Microsoft Windows Help File Content  |  1993-03-28  |  1KB  |  42 lines

  1. #!/bin/sh
  2. # Compressor for Unix executables.
  3. # Use this only for binaries that you do not use frequently.
  4. # The compressed version is a shell script which decompresses itself
  5. # after skipping 18 lines of shell commands.
  6. if test $# = 0; then
  7.   echo compress executables. original file foo is renamed to foo~
  8.   echo usage: `basename $0` files...
  9.   exit 1
  10. res=0
  11. for i do
  12.   if test ! -f $i ; then
  13.     echo `basename $0`: $i not found
  14.     res=1
  15.     continue
  16. # Try invoking the compressed executable with the original name:
  17.   sed "s,foo,$i," > g$$ <<'EOF'
  18. #!/bin/sh
  19. if tail +18 $0 | gzip -cd > /tmp/gztmp$$; then
  20.   chmod 755 /tmp/gztmp$$
  21.   if ln /tmp/gztmp$$ /tmp/foo 2>/dev/null; then
  22.     /tmp/foo $*
  23.     res=$?
  24.     /bin/rm -f /tmp/gztmp$$ /tmp/foo
  25.   else
  26.     /tmp/gztmp$$ $*
  27.     res=$?
  28.     /bin/rm -f /tmp/gztmp$$
  29.   echo Cannot decompress $0
  30.   exit 1
  31. exit $res
  32.   if gzip -cv9 $i >> g$$; then
  33.     /bin/rm -f $i~
  34.     mv $i $i~
  35.     mv g$$ $i
  36.     chmod 755 $i
  37.   else
  38.     /bin/rm -f g$$
  39.     echo `basename $0`: compression not possible for $i, file unchanged.
  40.     res=1
  41. exit $res
  42.