home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / AP / JED / JED097-1.TAR / jed / lib / shell.sl < prev    next >
Encoding:
Text File  |  1994-12-12  |  3.7 KB  |  174 lines

  1. %% system specific routines
  2.  
  3.  
  4. variable Shell_Last_Shell_Command = Null_String;
  5.  
  6. #ifdef VMS
  7. . ( 
  8. .   [cmd] =cmd
  9. .   [cfile file cmd]
  10. .   "vms_shell.com" expand_jedlib_file =cfile
  11. .   cfile strlen {"Unable to open vms_shell.com" error} !if
  12. .   "@" cfile strcat "/output=" strcat =cfile
  13.   
  14. .   "sys$login:_jed_shell.cmd_" =file
  15. .   cfile file strcat =cfile
  16.   
  17. .   " \"" cmd strcat "\"" strcat =cmd
  18. .   "starting process..." flush
  19. .   cfile cmd strcat system pop
  20. .   file insert_file pop
  21. .   file delete_file
  22. . ) shell_cmd
  23. #endif
  24.  
  25. #ifdef MSDOS
  26. . (
  27. .   [cmd] =cmd
  28. .   [file] "_jed_shll.cmd" =file
  29. .   cmd " &> " strcat file strcat =cmd
  30. .   "opening pipe..." flush
  31. .   cmd system 0 < {"system failed." error} if
  32. .   file insert_file pop
  33. .   file delete_file
  34. . ) shell_cmd
  35.  
  36. #endif 
  37.  
  38. #ifdef MSDOS VMS OS2
  39. #ifdef MSDOS OS2
  40. . (
  41. .   [dir n] =dir
  42.   % this bit will remove final slash on DOS unless it is root dir.
  43. .   dir strlen =n
  44. .   dir n 1 substr "\\" strcmp n 3 <= or
  45. .     { 
  46. .       dir 1 n 1 - substr =dir
  47. .     } !if
  48. .   dir 
  49. . ) msdos_fix_dir
  50. #endif
  51. #ifndef OS2
  52. . (
  53. .   [cmd n] 
  54. .   "Shell Command:"  Null_String Shell_Last_Shell_Command read_mini =cmd 
  55. .   cmd strlen {return} !if
  56. .   cmd =Shell_Last_Shell_Command
  57. .   getbuf_info pop pop exch pop
  58. #ifdef MSDOS
  59. .   msdos_fix_dir
  60. #endif
  61. .   change_default_dir {"Unable to chdir!" error} if
  62.  
  63. .   "*shell-output*" pop2buf erase_buffer
  64. .   cmd shell_cmd
  65. .   bob
  66. . ) do_shell_cmd
  67. #endif OS2
  68. #endif MSDOS VMS
  69.  
  70. #ifdef UNIX OS2
  71. . (
  72. .    [dir]
  73. .    [msg shbuf cmd] "*shell-output*" =shbuf "opening pipe..." =msg
  74. .    "Shell Command:"  Null_String Shell_Last_Shell_Command read_mini =cmd
  75. .    cmd strlen { return } !if
  76. .    cmd =Shell_Last_Shell_Command   
  77. .    "(" cmd strcat ")" strcat =cmd
  78. .    cmd " 2>&1" strcat =cmd
  79.    
  80. .    getbuf_info pop pop exch pop =dir
  81. .    dir change_default_dir {"Unable to chdir!" error} if
  82. .    shbuf pop2buf erase_buffer
  83. .    msg flush
  84. .    cmd shell_cmd bob
  85. .    msg "done" strcat flush
  86. . ) do_shell_cmd 
  87. #endif UNIX OS2
  88.  
  89. . (
  90. .   [km dir]  "*shell*" =km
  91.  
  92. .   km keymap_p { 
  93. .     km make_keymap
  94. .     "shell_input" "^M" km definekey
  95. .   } !if
  96. .   getbuf_info pop pop =dir pop
  97. #ifdef MSDOS OS2
  98. .   dir msdos_fix_dir =dir
  99. #endif
  100. .   dir change_default_dir {"Unable to chdir!" error} if
  101.   
  102.   
  103. .   km pop2buf
  104. .   km use_keymap
  105. .   "Current Directory is " insert dir insert newline
  106. #ifdef UNIX
  107. .    "% " insert
  108. #endif
  109. #ifdef MSDOS OS2
  110. .    "> " insert
  111. #endif
  112. #ifdef VMS
  113. .    "$ " insert
  114. #endif
  115. . ) shell
  116.  
  117.  
  118. . (
  119. .    [cmd tmp prompt]
  120. #ifdef UNIX
  121. .    "% " =prompt "/tmp/_jed_shell_" make_tmp_file =tmp
  122. #endif
  123. #ifdef MSDOS OS2
  124. .    "> " =prompt "jedshell." make_tmp_file =tmp
  125. #endif
  126. #ifdef VMS
  127. .    "$ " =prompt "sys$login:_jed_shell_." make_tmp_file =tmp
  128. #endif
  129.   
  130.    
  131. .    bol prompt skip_chars
  132. .    push_mark eol bufsubstr =cmd
  133. .    eob bol prompt skip_chars
  134. .    cmd looking_at {cmd insert} !if
  135. .    eol newline
  136. .    0 update  %% Update now so user see that things are ok
  137.    
  138. .    cmd strlen {
  139. .                 getbuf_info pop pop exch pop
  140. #ifdef MSDOS OS2
  141. .                 msdos_fix_dir
  142. #endif
  143. .         change_default_dir {"Unable to chdir!" error} if
  144.  
  145. #ifdef UNIX
  146. .                 "( " cmd strcat ")" strcat 
  147. .         " > " strcat tmp strcat " 2>&1" strcat
  148. #endif
  149. #ifdef MSDOS
  150. .                 cmd " &> " strcat tmp strcat
  151. #endif
  152. #ifdef OS2
  153. .                 cmd " > " strcat tmp strcat 
  154. #endif
  155. #ifdef VMS
  156. .                "vms_shell.com" expand_jedlib_file dup
  157. .            strlen {pop "Unable to find vms_shell.com" error} !if
  158. .                "@" exch strcat 
  159. .            "/output=" strcat tmp strcat
  160. .            " " strcat cmd strcat 
  161. #endif
  162. .      system pop
  163. .      tmp insert_file pop
  164. .      tmp delete_file pop
  165. .    } if
  166.    
  167. .    bolp {prompt}{"\n" prompt strcat} else insert
  168. #ifdef OS2
  169. .  1 update %% Update due to problems with Borland C
  170. #endif
  171.  
  172. . ) shell_input
  173.  
  174.