runrc.cmd 1.7 KB

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