OSDN Git Service

add template for hook scripts
[redminele/redminele.git] / installer / ant / bin / runrc.cmd
1 /* \r
2    Licensed to the Apache Software Foundation (ASF) under one or more\r
3    contributor license agreements.  See the NOTICE file distributed with\r
4    this work for additional information regarding copyright ownership.\r
5    The ASF licenses this file to You under the Apache License, Version 2.0\r
6    (the "License"); you may not use this file except in compliance with\r
7    the License.  You may obtain a copy of the License at\r
8 \r
9        http://www.apache.org/licenses/LICENSE-2.0\r
10 \r
11    Unless required by applicable law or agreed to in writing, software\r
12    distributed under the License is distributed on an "AS IS" BASIS,\r
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14    See the License for the specific language governing permissions and\r
15    limitations under the License.\r
16 \r
17    Run RC file, name is in the first arg, second arg is either PATH\r
18    ENV  or -r or nothing \r
19 */\r
20 \r
21 parse arg name path rest\r
22 \r
23 if name = '' then do\r
24   say 'RC file name is missing'\r
25   exit 1\r
26 end\r
27 \r
28 if rest \= '' then do\r
29   say 'Too many parameters'\r
30   exit 1\r
31 end\r
32 \r
33 call runit name path\r
34 exit 0\r
35 \r
36 runit: procedure\r
37 parse arg name path dir\r
38 \r
39 if path \= '' & path \= '-r' then do\r
40   dir = value(translate(path),,'OS2ENVIRONMENT')\r
41   if dir = '' then return\r
42   dir = translate(dir, '\', '/') /* change UNIX-like path to OS/2 */\r
43 end\r
44 \r
45 if dir = '' then dir = directory()\r
46 \r
47 if path = '-r' then do /* recursive call */\r
48   subdir = filespec('path', dir)\r
49   if subdir \= '\' then do\r
50     subdir = left(subdir, length(subdir)-1)\r
51     call runit name path filespec('drive', dir) || subdir\r
52   end\r
53 end\r
54 \r
55 /* Look for the file and run it */\r
56 if right(dir, 1) \= '\' then dir = dir || '\'\r
57 rcfile = stream(dir || name, 'c', 'query exists')\r
58 if rcfile \= '' then interpret 'call "' || rcfile || '"'\r
59 \r
60 return\r