8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / bnu / uuto
blobd57e35e6dd06a07c75d6cf87eed4dad5849e5fd4
1 #!/bin/sh
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
8 # with the License.
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
21 # CDDL HEADER END
24 # Copyright 1995 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
27 #ident "%Z%%M% %I% %E% SMI"
29 uuto () {
30 f=""
31 d=""
32 error="0"
33 # get file names
34 # files must be readable,
35 # directories must be readable/searchable
36 # otherwise increment error count and skip it.
37 while test $# -ge 1
39 if test -d "$1" -a {"$1" = "." -o "$1" = ".."}
40 then shift; continue
41 elif test -r "$1" -a -f "$1"
42 then f="$f $1"
43 elif test -r "$1" -a -x "$1" -a -d "$1"
44 then d="$d $1"
45 else error=`expr 0$error + 1`
46 if test -f "$1"; then
47 printf "`gettext 'uuto: %s%s: file not readable'`\n" $UUP $1 >&2
48 elif test -d "$1"; then
49 printf "`gettext 'uuto: %s%s: directory not readable/searchable'`\n" $UUP $1 >&2
50 else
51 printf "`gettext 'uuto: %s%s: file/directory not found'`\n" $UUP $1 >&2
54 shift
55 done
56 if test -n "$d" -a -n "$user"
57 then
58 for i in $d
60 ( cd $i; UUP="$UUP$i/"
61 uuto * $1)
62 error=`expr 0$error + 0$?`
63 done
66 if test -n "$f" -a -n "$user"
67 then
68 uucp $a $f $remote!~/receive/$user/$mysys/$UUP
69 error=`expr 0$error + 0$?`
72 return $error
75 # main uuto shell
77 export IFS PATH
78 IFS="
80 PATH="/usr/bin"
82 a=""
83 temp=""
84 mysys=`uuname -l`
85 mesg="Usage: uuto [-mp] files remote!user\n"
87 trap "trap '' 0; exit $?" 1 2 3 13 15
88 copy=0
89 # get options
90 while getopts mp FLAG; do
91 case $FLAG in
92 m) a="$a -m"
94 p) a="$a -C"
95 copy=1 ;;
96 ?) gettext "$mesg" >&2
97 exit 1
99 esac
100 done
101 shift `expr $OPTIND - 1`
103 # be sure have both files and destination
104 if test $# -lt 2
105 then
106 gettext "$mesg" >&2
107 exit 1
109 # skip file names to get to destination
110 while test $# -gt 1
112 temp="$temp $1"
113 shift
114 done
115 # the recipient arg: remote!user
116 # remote may be omitted (default is this machine)
117 # must have at least !user
118 remote=`expr $1 : '\(.*\)!'`
119 user=`expr $1 : '.*!\(.*\)'`
120 if test -z "$user"
121 then
122 gettext "uuto: incomplete destination -- must specify user\n" >&2
123 gettext "$mesg" >&2
124 exit 1
126 a="$a -d -n $user"
128 UUP=""
129 uuto $temp
131 exit $error