summaryrefslogtreecommitdiff
path: root/vms/gawk_alias_setup.com
blob: a7f13f4b9cd6a683926aef2b85af33a8416465b6 (plain)
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
$! File: gawk_alias_setup.com
$!
$! The PCSI procedure needs a helper script to set up and remove aliases.
$!
$! If p1 starts with "R" then remove instead of install.
$!
$!
$! 02-Jan-2014  J. Malmberg - Gawk Version
$!
$!===========================================================================
$!
$ mode = "install"
$ code = f$extract(0, 1, p1)
$ if code .eqs. "R" .or. code .eqs. "r" then mode = "remove"
$!
$ arch_type = f$getsyi("ARCH_NAME")
$ arch_code = f$extract(0, 1, arch_type)
$!
$ if arch_code .nes. "V"
$ then
$   set proc/parse=extended
$ endif
$!
$!
$ call do_alias "gawk" "[bin]"
$ call do_alias "gawk" "[bin]" "awk"
$ call do_alias "gawk" "[bin]" "gawk" "[usr.bin]"
$ call do_alias "gawk" "[bin]" "awk" "[usr.bin]"
$ call do_alias "gawk.1" "[usr.share.man.man1]" "awk.1"
$!
$ exit
$!!
$!
$do_alias: subroutine
$ if mode .eqs. "install"
$ then
$   call add_alias "''p1'" "''p2'" "''p3'" "''p4'"
$ else
$   call remove_alias "''p1'" "''p2'" "''p3'" "''p4'"
$ endif
$ exit
$ENDSUBROUTINE ! do_alias
$!
$!
$! P1 is the filename, p2 is the directory prefix,
$! p3 is the alias name if different than p1
$! p4 is the alias directory if different than p2
$add_alias: subroutine
$ if p3 .eqs. "" then p3 = p1
$ if p4 .eqs. "" then p4 = p2
$ ftype = f$element(1, ".", p1)
$ if ftype .eqs. "."
$ then
$    file = "gnv$gnu:''p2'gnv$''p1'.EXE"
$    alias = "gnv$gnu:''p4'''p3'."
$ else
$    file = "gnv$gnu:''p2'''p1'"
$    alias = "gnv$gnu:''p4'''p3'"
$ endif
$ if f$search(file) .nes. ""
$ then
$   fid = ""
$   mess = f$environment("message")
$   if f$search(alias) .nes. ""
$   then
$      on warn then goto fix_link
$      set message/nofac/nosev/noident/notext
$      fid = f$file_attributes(alias, "FID")
$   endif
$   goto fix_link_end
$fix_link:
$    set file/remove 'alias';
$fix_link_end:
$   set message'mess'
$   if f$search(alias) .eqs. ""
$   then
$       set file/enter='alias' 'file'
$   endif
$   alias1 = alias + "exe"
$   if (ftype .eqs. ".")
$   then
$     fid = ""
$     mess = f$environment("message")
$     if f$search(alias1) .nes. ""
$     then
$       on warn then goto fix_link1
$       set message/nofac/nosev/noident/notext
$       fid = f$file_attributes(alias1, "FID")
$     endif
$     goto fix_link_end1
$fix_link1:
$    set file/remove 'alias1';
$fix_link_end1:
$   set message'mess'
$     if (f$search(alias1) .eqs. "")
$     then
$       set file/enter='alias1' 'file'
$     endif
$   endif
$ endif
$ exit
$ENDSUBROUTINE ! add_alias
$!
$remove_alias: subroutine
$ if p3 .eqs. "" then p3 = p1
$ if p4 .eqs. "" then p4 = p2
$ ftype = f$element(1, ".", p1)
$ if ftype .eqs. "."
$ then
$   file = "gnv$gnu:''p2'gnv$''p1'.EXE"
$   alias = "gnv$gnu:''p4'''p3'."
$ else
$   file = "gnv$gnu:''p2'''p1'"
$   alias = "gnv$gnu:''p4'''p3'"
$ endif
$ file_fid = "No_file_fid"
$ if f$search(file) .nes. ""
$ then
$   fid = f$file_attributes(file, "FID")
$   if f$search(alias) .nes. ""
$   then
$       afid = f$file_attributes(alias, "FID")
$       if (afid .eqs. fid)
$       then
$           set file/remove 'alias';
$       endif
$   endif
$   alias1 = alias + "exe"
$   if (ftype .eqs. ".") .and. (f$search(alias1) .nes. "")
$   then
$       afid = f$file_attributes(alias1, "FID")
$       if (afid .eqs. fid)
$       then
$           set file/remove 'alias1';
$       endif
$   endif
$ endif
$ exit
$ENDSUBROUTINE ! remove_alias