File: cshwish.head

package info (click to toggle)
afbackup 3.1beta1-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 1,500 kB
  • ctags: 1,685
  • sloc: ansic: 22,406; csh: 3,597; tcl: 964; sh: 403; makefile: 200
file content (122 lines) | stat: -rw-r--r-- 2,588 bytes parent folder | download | duplicates (2)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#! /bin/csh -f

if (! $?BACKUP_HOME) then
  set p=$0
  set pnam=$p
  set pnam=$pnam:t
  if ($pnam == $0) then
    foreach dir ($path)
      if (-x $dir/$pnam) then
	set p=$dir/$pnam
	break
      endif
    end
  endif
  if (`echo $p|cut -c1` != "/") then
    set p=`pwd`/$p
  endif

  set oldpath=$p

 restart_resolv:
  set newpath="$oldpath"_
  while ("$newpath" != "$oldpath")
    set newpath="$oldpath"

    set oldpath=`echo "$oldpath"|sed 's#/\./#/#g;s#/\.$##g;s#//*#/#g;s#^\./##g;s#^/\.\./#/#g'`

    if ("$oldpath" != '/') then
      set oldpath=`echo "$oldpath"|sed 's#/*$##g'`
    endif
  end

  if (`echo "$oldpath"|cut -c1` == "/") then
    set oldhead="/"`echo "$oldpath"|cut -c2-|sed 's#/.*$##g'`
    set oldtail=`echo "$oldpath"|cut -c2-|sed 's#^[^/]*/##'`
  else
    set oldhead=`echo "$oldpath"|sed 's#/.*$##g'`
    set oldtail=`echo "$oldpath"|sed 's#^[^/]*/##'`
  endif
  if ("$oldpath" == "$oldhead") set oldtail=""

  while (1)
    if ("$oldhead" == "") set oldhead="."
    if (! -f "$oldhead" && ! -d "$oldhead") then
      set newpath=""
      goto getout_1
    endif

    set linkchar=`ls -ld "$oldhead"|cut -c1`
    if ($linkchar == 'l') then
      set points_to=`ls -ld "$oldhead"|sed 's#^.*->[ 	]*##g'`

      if (`echo "$points_to"|cut -c1` == '/') then
        set newpath="$points_to"/"$oldtail"
      else
        set newpath=`dirname "$oldhead"`/"$points_to"/"$oldtail"
      endif

      set oldpath="$newpath"
      goto restart_resolv
    endif

    if ("$oldtail" == "") then
      set oldpath="$oldhead"
      break
    endif

    set oldhead="$oldhead"/`echo "$oldtail"|sed 's#/.*$##g'`
    if (`echo "$oldtail"|grep /|wc -l` < 1) then
      set oldtail=''
    else
      set oldtail=`echo "$oldtail"|sed 's#^[^/]*/##g'`
    endif
  end

  set newpath="$oldpath"_
  while ("$newpath" != "$oldpath")
    set newpath="$oldpath"

    set oldpath=`echo $oldpath|sed 's#[^/][^/]*/\.\./##g;s#[^/][^/]*/\.\.$##g;s#/\./#/#g;s#/\.$##g;s#//*#/#g;s#^\./##g;s#^/\.\./#/#g'`

    if ("$oldpath" != '/') then
      set oldpath=`echo "$oldpath"|sed 's#/*$##g'`
    endif
  end

 getout_1:

  set p="$newpath"
  set p=$p:h

  setenv BACKUP_HOME $p:h
endif


unalias ls
set WISH=""
foreach dir ($path)
  if (! -d $dir) then
    continue
  endif

  set progs=`ls $dir|egrep '^wish([0-9]+[.]?)*$'`
  foreach prog ($progs)
    if (-x $dir/$prog) then
      set WISH=$dir/$prog
      break
    endif
  end

  if ("$WISH" != "") then
    break
  endif
end

if ("$WISH" == "") then
  echo "Error: window shell wish not found. Exiting."
  exit 1
endif

$WISH << END_OF_INPUT