You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

runrc.cmd 1.6KB

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