1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-15 04:55:22 +02:00

[249715] [dstore][shells] Unix shell does not echo command

This commit is contained in:
David McKnight 2008-11-25 14:37:58 +00:00
parent 5172b0a6e1
commit fd74b97350
2 changed files with 38 additions and 12 deletions

View file

@ -18,6 +18,7 @@
* Noriaki Takatsu (IBM) - [220126] [dstore][api][breaking] Single process server for multiple clients
* David McKnight (IBM) [224906] [dstore] changes for getting properties and doing exit due to single-process capability
* David McKnight (IBM) [250203] [dstore][shells]%var% is substituted to null in Unix shell
* David McKnight (IBM) [249715] [dstore][shells] Unix shell does not echo command
*******************************************************************************/
package org.eclipse.rse.internal.dstore.universal.miners.command;
@ -613,6 +614,9 @@ public class CommandMinerThread extends MinerThread
writer.newLine();
writer.flush();
// for bug 249715 - keeping track of time of last input
// in order know when to stop waiting for output
_stdOutputHandler.setTimeOfLastInput(System.currentTimeMillis());
if (!_isWindows && (input.startsWith("cd ") || input.equals("cd"))) //$NON-NLS-1$ //$NON-NLS-2$
{

View file

@ -14,6 +14,7 @@
* Contributors:
* David McKnight (IBM) - [207178] changing list APIs for file service and subsystems
* David McKnight (IBM) - [243699] [dstore] Loop in OutputHandler
* David McKnight (IBM) [249715] [dstore][shells] Unix shell does not echo command
*******************************************************************************/
package org.eclipse.rse.internal.dstore.universal.miners.command;
@ -53,6 +54,9 @@ public class OutputHandler extends Handler {
private boolean _endOfStream = false;
private List _encodings;
// for bug 249715
private long _timeOfLastInput = 0;
public OutputHandler(DataInputStream reader, String qualifier,
boolean isTerminal, boolean isStdError, boolean isShell,
@ -83,6 +87,9 @@ public class OutputHandler extends Handler {
}
public void setTimeOfLastInput(long time){
_timeOfLastInput = time;
}
public void handle() {
@ -99,8 +106,9 @@ public class OutputHandler extends Handler {
_commandThread.interpretLine(line, _isStdError);
}
if (!_isTerminal)
if (!_isTerminal){
doPrompt();
}
_commandThread.refreshStatus();
} else {
@ -113,12 +121,11 @@ public class OutputHandler extends Handler {
if ((_reader.available() == 0) && !_isStdError && _isShell) {
if (!_isTerminal) {
try {
Thread.sleep(500);
Thread.sleep(200);
if (_reader.available() == 0) {
// create fake prompt
_commandThread.createPrompt(
_commandThread.getCWD() + '>',
_commandThread.getCWD());
String cwd = _commandThread.getCWD();
_commandThread.createPrompt(cwd + '>', cwd);
}
} catch (Exception e) {
}
@ -161,13 +168,28 @@ public class OutputHandler extends Handler {
int lookahead = 0;
// redetermine available if none available now
// re-determine available if none available now
if (available == 0) {
lookahead = _reader.read();
if (lookahead == -1) {
return null;
} else {
available = _reader.available() + 1;
if (!_isStdError && !_isTerminal){
long lastInput = _timeOfLastInput;
while (lastInput == _timeOfLastInput && _keepRunning){ // once there's something new, we can stop waiting
Thread.sleep(500); // wait in case there is something
}
// it's possible that there is no output for something
// in the non-TTY case we need to prompt
available = checkAvailable();
if (available == 0){
return new String[0];
}
}
else {
lookahead = _reader.read();
if (lookahead == -1) {
return null;
} else {
available = _reader.available() + 1;
}
}
}
@ -203,7 +225,7 @@ public class OutputHandler extends Handler {
try {
String fullOutput = new String(readBytes, 0, numRead,
encoding);
// if output is not null, we assume the encoding was correct
// and process the output
if (fullOutput != null) {