1402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 2402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Licensed to the Apache Software Foundation (ASF) under one or more 3402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll contributor license agreements. See the NOTICE file distributed with 4402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this work for additional information regarding copyright ownership. 5402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll The ASF licenses this file to You under the Apache License, Version 2.0 6402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll (the "License"); you may not use this file except in compliance with 7402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll the License. You may obtain a copy of the License at 8402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 9402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll http://www.apache.org/licenses/LICENSE-2.0 10402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 11402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Unless required by applicable law or agreed to in writing, software 12402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll distributed under the License is distributed on an "AS IS" BASIS, 13402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll See the License for the specific language governing permissions and 15402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll limitations under the License. 16402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 17402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Run RC file, name is in the first arg, second arg is either PATH 18402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ENV or -r or nothing 19402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll*/ 20402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 21402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollparse arg name path rest 22402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 23402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollif name = '' then do 24402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll say 'RC file name is missing' 25402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll exit 1 26402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollend 27402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 28402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollif rest \= '' then do 29402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll say 'Too many parameters' 30402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll exit 1 31402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollend 32402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 33402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollcall runit name path 34402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollexit 0 35402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 36402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollrunit: procedure 37402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollparse arg name path dir 38402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 39402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollif path \= '' & path \= '-r' then do 40402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll dir = value(translate(path),,'OS2ENVIRONMENT') 41402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if dir = '' then return 42402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll dir = translate(dir, '\', '/') /* change UNIX-like path to OS/2 */ 43402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollend 44402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 45402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollif dir = '' then dir = directory() 46402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 47402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollif path = '-r' then do /* recursive call */ 48402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll subdir = filespec('path', dir) 49402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if subdir \= '\' then do 50402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll subdir = left(subdir, length(subdir)-1) 51402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll call runit name path filespec('drive', dir) || subdir 52402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll end 53402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollend 54402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 55402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* Look for the file and run it */ 56402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollif right(dir, 1) \= '\' then dir = dir || '\' 57402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollrcfile = stream(dir || name, 'c', 'query exists') 58402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollif rcfile \= '' then interpret 'call "' || rcfile || '"' 59402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 60402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollreturn 61