Changeset 3803
- Timestamp:
- 09/16/03 00:44:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/j/Shell.java
r2655 r3803 3 3 * 4 4 * Copyright (C) 1998-2003 Peter Graves 5 * $Id: Shell.java,v 1.2 7 2003-06-29 00:19:34piso Exp $5 * $Id: Shell.java,v 1.28 2003-09-16 00:44:00 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 55 55 this(); 56 56 this.shellCommand = shellCommand; 57 if (shellCommand .indexOf("tcsh") >= 0)57 if (shellCommand != null && shellCommand.indexOf("tcsh") >= 0) 58 58 promptIsStderr = false; 59 59 } … … 82 82 String s = 83 83 Editor.preferences().getStringProperty(Property.SHELL_FILE_NAME); 84 if (s != null )84 if (s != null && s.length() > 0) 85 85 return s; 86 86 return Platform.isPlatformWindows() ? "cmd.exe" : "bash -i"; … … 94 94 private static Shell createShell(String shellCommand) 95 95 { 96 if (shellCommand == null) { 97 Debug.bug(); 98 return null; 99 } 96 100 Shell shell = new Shell(shellCommand); 97 101 shell.startProcess(); … … 109 113 protected void startProcess() 110 114 { 115 if (shellCommand == null) { 116 Debug.bug(); 117 return; 118 } 111 119 if (Platform.isPlatformWindows()) 112 120 if (shellCommand.toLowerCase().indexOf("cmd.exe") < 0) 113 121 cygnify = true; 114 115 122 // Only set initialDir the first time we run, so that if we restart 116 123 // this shell, it will start up in the same directory each time. … … 120 127 initialDir = Directories.getUserHomeDirectory(); 121 128 } 122 123 129 // Shell command may contain a space (e.g. "bash -i"). 124 130 StringTokenizer st = new StringTokenizer(shellCommand); 125 126 131 String[] cmdArray; 127 132 int i = 0; … … 133 138 while (st.hasMoreTokens()) 134 139 cmdArray[i++] = st.nextToken(); 135 136 140 Process p = null; 137 141 try { … … 144 148 return; 145 149 } 146 147 150 currentDir = initialDir; 148 151 startWatcherThread(); 149 150 152 // See if the process exits right away (meaning jpty couldn't launch 151 153 // the shell command). … … 160 162 if (getProcess() == null) 161 163 return; // Process exited. 162 163 164 setPromptRE(Editor.preferences().getStringProperty( 164 165 Property.SHELL_PROMPT_PATTERN)); 165 166 166 try { 167 167 stdin = new OutputStreamWriter(p.getOutputStream()); … … 437 437 public String toString() 438 438 { 439 return shellCommand; 440 } 441 442 public String getTitle() 443 { 444 String dir = currentDir.toString(); 445 446 // Upper case drive letter. 447 if (Platform.isPlatformWindows() && dir.length() >= 2 && dir.charAt(1) == ':') 448 dir = Character.toUpperCase(dir.charAt(0)) + dir.substring(1); 449 450 return shellCommand + " " + dir; 439 return shellCommand != null ? shellCommand : ""; 451 440 } 452 441 … … 588 577 public static void shell(String shellCommand) 589 578 { 579 if (shellCommand == null) { 580 Debug.bug(); 581 return; 582 } 590 583 if (!Editor.checkExperimental()) 591 584 return; … … 605 598 Buffer b = it.nextBuffer(); 606 599 if (b instanceof Shell) { 607 if ( ((Shell)b).shellCommand.equals(shellCommand)) {600 if (shellCommand.equals(((Shell)b).shellCommand)) { 608 601 buf = b; 609 602 break;
Note: See TracChangeset
for help on using the changeset viewer.