| 1 |
$! File: gawk_alias_setup.com |
| 2 |
$! |
| 3 |
$! The PCSI procedure needs a helper script to set up and remove aliases. |
| 4 |
$! |
| 5 |
$! If p1 starts with "R" then remove instead of install. |
| 6 |
$! |
| 7 |
$! |
| 8 |
$! 02-Jan-2014 J. Malmberg - Gawk Version |
| 9 |
$! |
| 10 |
$!=========================================================================== |
| 11 |
$! |
| 12 |
$ mode = "install" |
| 13 |
$ code = f$extract(0, 1, p1) |
| 14 |
$ if code .eqs. "R" .or. code .eqs. "r" then mode = "remove" |
| 15 |
$! |
| 16 |
$ arch_type = f$getsyi("ARCH_NAME") |
| 17 |
$ arch_code = f$extract(0, 1, arch_type) |
| 18 |
$! |
| 19 |
$ if arch_code .nes. "V" |
| 20 |
$ then |
| 21 |
$ set proc/parse=extended |
| 22 |
$ endif |
| 23 |
$! |
| 24 |
$! |
| 25 |
$ call do_alias "gawk" "[usr.bin]" |
| 26 |
$ call do_alias "gawk" "[usr.bin]" "awk" |
| 27 |
$ call do_alias "gawk.1" "[usr.share.man.man1]" "awk.1" |
| 28 |
$! |
| 29 |
$ exit |
| 30 |
$!! |
| 31 |
$! |
| 32 |
$do_alias: subroutine |
| 33 |
$ if mode .eqs. "install" |
| 34 |
$ then |
| 35 |
$ call add_alias "''p1'" "''p2'" "''p3'" "''p4'" |
| 36 |
$ else |
| 37 |
$ call remove_alias "''p1'" "''p2'" "''p3'" "''p4'" |
| 38 |
$ endif |
| 39 |
$ exit |
| 40 |
$ENDSUBROUTINE ! do_alias |
| 41 |
$! |
| 42 |
$! |
| 43 |
$! P1 is the filename, p2 is the directory prefix, |
| 44 |
$! p3 is the alias name if different than p1 |
| 45 |
$! p4 is the alias directory if different than p2 |
| 46 |
$add_alias: subroutine |
| 47 |
$ if p3 .eqs. "" then p3 = p1 |
| 48 |
$ if p4 .eqs. "" then p4 = p2 |
| 49 |
$ ftype = f$element(1, ".", p1) |
| 50 |
$ if ftype .eqs. "." |
| 51 |
$ then |
| 52 |
$ file = "gnv$gnu:''p2'gnv$''p1'.EXE" |
| 53 |
$ alias = "gnv$gnu:''p4'''p3'." |
| 54 |
$ else |
| 55 |
$ file = "gnv$gnu:''p2'''p1'" |
| 56 |
$ alias = "gnv$gnu:''p4'''p3'" |
| 57 |
$ endif |
| 58 |
$ if f$search(file) .nes. "" |
| 59 |
$ then |
| 60 |
$ fid = "" |
| 61 |
$ mess = f$environment("message") |
| 62 |
$ if f$search(alias) .nes. "" |
| 63 |
$ then |
| 64 |
$ on warn then goto fix_link |
| 65 |
$ set message/nofac/nosev/noident/notext |
| 66 |
$ fid = f$file_attributes(alias, "FID") |
| 67 |
$ endif |
| 68 |
$ goto fix_link_end |
| 69 |
$fix_link: |
| 70 |
$ set file/remove 'alias'; |
| 71 |
$fix_link_end: |
| 72 |
$ set message'mess' |
| 73 |
$ if f$search(alias) .eqs. "" |
| 74 |
$ then |
| 75 |
$ set file/enter='alias' 'file' |
| 76 |
$ endif |
| 77 |
$ alias1 = alias + "exe" |
| 78 |
$ if (ftype .eqs. ".") |
| 79 |
$ then |
| 80 |
$ fid = "" |
| 81 |
$ mess = f$environment("message") |
| 82 |
$ if f$search(alias1) .nes. "" |
| 83 |
$ then |
| 84 |
$ on warn then goto fix_link1 |
| 85 |
$ set message/nofac/nosev/noident/notext |
| 86 |
$ fid = f$file_attributes(alias1, "FID") |
| 87 |
$ endif |
| 88 |
$ goto fix_link_end1 |
| 89 |
$fix_link1: |
| 90 |
$ set file/remove 'alias1'; |
| 91 |
$fix_link_end1: |
| 92 |
$ set message'mess' |
| 93 |
$ if (f$search(alias1) .eqs. "") |
| 94 |
$ then |
| 95 |
$ set file/enter='alias1' 'file' |
| 96 |
$ endif |
| 97 |
$ endif |
| 98 |
$ endif |
| 99 |
$ exit |
| 100 |
$ENDSUBROUTINE ! add_alias |
| 101 |
$! |
| 102 |
$remove_alias: subroutine |
| 103 |
$ if p3 .eqs. "" then p3 = p1 |
| 104 |
$ if p4 .eqs. "" then p4 = p2 |
| 105 |
$ ftype = f$element(1, ".", p1) |
| 106 |
$ if ftype .eqs. "." |
| 107 |
$ then |
| 108 |
$ file = "gnv$gnu:''p2'gnv$''p1'.EXE" |
| 109 |
$ alias = "gnv$gnu:''p4'''p3'." |
| 110 |
$ else |
| 111 |
$ file = "gnv$gnu:''p2'''p1'" |
| 112 |
$ alias = "gnv$gnu:''p4'''p3'" |
| 113 |
$ endif |
| 114 |
$ file_fid = "No_file_fid" |
| 115 |
$ if f$search(file) .nes. "" |
| 116 |
$ then |
| 117 |
$ fid = f$file_attributes(file, "FID") |
| 118 |
$ if f$search(alias) .nes. "" |
| 119 |
$ then |
| 120 |
$ afid = f$file_attributes(alias, "FID") |
| 121 |
$ if (afid .eqs. fid) |
| 122 |
$ then |
| 123 |
$ set file/remove 'alias'; |
| 124 |
$ endif |
| 125 |
$ endif |
| 126 |
$ alias1 = alias + "exe" |
| 127 |
$ if (ftype .eqs. ".") .and. (f$search(alias1) .nes. "") |
| 128 |
$ then |
| 129 |
$ afid = f$file_attributes(alias1, "FID") |
| 130 |
$ if (afid .eqs. fid) |
| 131 |
$ then |
| 132 |
$ set file/remove 'alias1'; |
| 133 |
$ endif |
| 134 |
$ endif |
| 135 |
$ endif |
| 136 |
$ exit |
| 137 |
$ENDSUBROUTINE ! remove_alias |