File: mailshar.in

package info (click to toggle)
sharutils 1:4.2-6
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 1,436 kB
  • ctags: 587
  • sloc: ansic: 6,313; perl: 1,742; makefile: 563; sh: 495; pascal: 293; sed: 93
file content (87 lines) | stat: -rwxr-xr-x 2,153 bytes parent folder | download | duplicates (5)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/sh
# Mail a multi-part shar from a list of files.
# Copyright (C) 1990, 1994, 1995 Free Software Foundation, Inc.
# Fran´┐Żois Pinard <pinard@iro.umontreal.ca>, 1991.

package="@PACKAGE@"
version="@VERSION@"

prefix='@prefix@'
bindir="@exec_prefix@/bin"
transform='@program_transform_name@'

shar=$bindir/`echo shar | sed "$transform"`
mail_files=$bindir/`echo mail-files | sed "$transform"`

progname=`echo $0 | sed -e 's,.*/,,'`

usage="\
Usage: $progname [OPTION...] DEST FILE ...

with OPTION in:
      --help      display this help and exit
      --version   output version information and exit

  -s SIZE         decide size of each part in Kb, default 60
  -M              decide how to send each file separately
  -T              avoid calling compress, gzip nor uuencode
  -B              force calling uuencode
  -z              force calling gzip and uuencode
  -Z              force calling compress and uuencode
  -x              trace script

If none of -MTBzZ are given, -z is automatically selected if *none*
of the FILEs have an .arc, .exz, .gif, .z, .gz, .Z, .zip or .zoo suffix."

temp=`tempfile`

### Decode the options.

size=60

while test $# -gt 0; do
  case $1 in
    -s) if test $# -gt 1; then size=$2; shift 2;
        else echo "$usage"; exit 1; fi ;;
    -[MTBzZ]) mode=$1; shift ;;
    -x) trace=-x; set -x; shift ;;
    --v* ) echo "$progname - $package $version"; exit 0 ;;
    --h* ) echo "$usage"; exit 0 ;;
    -) break ;;
    -*) echo "Try \`$progname --help' for more information."; exit 1 ;;
    *) break
  esac
done

if test $# -lt 2; then
  echo "$usage"
  exit 1
fi

dest="$1"
shift
subject="$*"

### Check if we should gzip.

if test -z "$mode"; then
  mode=-z
  find $* -type f -print 2> /dev/null > $temp
  while read file; do
    case "`echo $file | sed -n 's|.*/||;/\./s|.*\.||p' \
	| tr '[A-Z]' '[a-z]'`" in
      arc|exz|gif|gz|z|zip|zoo) mode=; break ;;
    esac
  done < $temp
  rm $temp
fi

### Construct the multi-part shar files and mail them.

$shar $mode -P -L$size -o$temp -c -F $* \
  && $mail_files $trace $dest shar "$subject" $temp* \
  && rm ${temp}* \
  && exit 0

rm -f ${temp}*
exit 1