-
Notifications
You must be signed in to change notification settings - Fork 8
/
rdiff
executable file
·38 lines (34 loc) · 912 Bytes
/
rdiff
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
#!/bin/csh -f
# rdiff (csh script) -- compares a file with its equivalent on a given host
# Usage: rdiff [-e [-1]] <file> [ <user>@<host> ]
while (x$1 =~ x-*)
if (x$1 == x-e) set option_e
if (x$1 == x-1) set option_1
shift
end
set remote_sh = rsh
if ($?option_e) then
set remote_sh = ssh`if ($?option_1) echo 1`
endif
if ($#argv == 0) then
sh -c "echo ${0}: 'a file (and optionally a user-identifier) must be specified'"
set exit_code = 1
else
if ($#argv == 1) then
if (! $?REMOTEHOST) then
sh -c "echo ${0}: '<REMOTEHOST> is not set' >&2"
set exit_code = 2
else
set address = "$REMOTEHOST -l $REMOTEUSER"
endif
else
set address = "`echo $2 | sed -e 's/\(.*\)@\(.*\)/\2 -l \1/'`"
endif
if (! $?exit_code) then
$remote_sh $address cat $1 | diff -c - $1
endif
endif
endif
if ($?exit_code) then
exit $exit_code
endif