mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 13:05:22 +02:00
[249715] [dstore][shells] Unix shell does not echo command
This commit is contained in:
parent
5172b0a6e1
commit
fd74b97350
2 changed files with 38 additions and 12 deletions
|
@ -18,6 +18,7 @@
|
||||||
* Noriaki Takatsu (IBM) - [220126] [dstore][api][breaking] Single process server for multiple clients
|
* 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) [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) [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;
|
package org.eclipse.rse.internal.dstore.universal.miners.command;
|
||||||
|
@ -613,6 +614,9 @@ public class CommandMinerThread extends MinerThread
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
writer.flush();
|
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$
|
if (!_isWindows && (input.startsWith("cd ") || input.equals("cd"))) //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* David McKnight (IBM) - [207178] changing list APIs for file service and subsystems
|
* David McKnight (IBM) - [207178] changing list APIs for file service and subsystems
|
||||||
* David McKnight (IBM) - [243699] [dstore] Loop in OutputHandler
|
* 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;
|
package org.eclipse.rse.internal.dstore.universal.miners.command;
|
||||||
|
@ -54,6 +55,9 @@ public class OutputHandler extends Handler {
|
||||||
|
|
||||||
private List _encodings;
|
private List _encodings;
|
||||||
|
|
||||||
|
// for bug 249715
|
||||||
|
private long _timeOfLastInput = 0;
|
||||||
|
|
||||||
public OutputHandler(DataInputStream reader, String qualifier,
|
public OutputHandler(DataInputStream reader, String qualifier,
|
||||||
boolean isTerminal, boolean isStdError, boolean isShell,
|
boolean isTerminal, boolean isStdError, boolean isShell,
|
||||||
CommandMinerThread commandThread) {
|
CommandMinerThread commandThread) {
|
||||||
|
@ -83,6 +87,9 @@ public class OutputHandler extends Handler {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTimeOfLastInput(long time){
|
||||||
|
_timeOfLastInput = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void handle() {
|
public void handle() {
|
||||||
|
@ -99,8 +106,9 @@ public class OutputHandler extends Handler {
|
||||||
_commandThread.interpretLine(line, _isStdError);
|
_commandThread.interpretLine(line, _isStdError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_isTerminal)
|
if (!_isTerminal){
|
||||||
doPrompt();
|
doPrompt();
|
||||||
|
}
|
||||||
|
|
||||||
_commandThread.refreshStatus();
|
_commandThread.refreshStatus();
|
||||||
} else {
|
} else {
|
||||||
|
@ -113,12 +121,11 @@ public class OutputHandler extends Handler {
|
||||||
if ((_reader.available() == 0) && !_isStdError && _isShell) {
|
if ((_reader.available() == 0) && !_isStdError && _isShell) {
|
||||||
if (!_isTerminal) {
|
if (!_isTerminal) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(500);
|
Thread.sleep(200);
|
||||||
if (_reader.available() == 0) {
|
if (_reader.available() == 0) {
|
||||||
// create fake prompt
|
// create fake prompt
|
||||||
_commandThread.createPrompt(
|
String cwd = _commandThread.getCWD();
|
||||||
_commandThread.getCWD() + '>',
|
_commandThread.createPrompt(cwd + '>', cwd);
|
||||||
_commandThread.getCWD());
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
@ -161,13 +168,28 @@ public class OutputHandler extends Handler {
|
||||||
|
|
||||||
int lookahead = 0;
|
int lookahead = 0;
|
||||||
|
|
||||||
// redetermine available if none available now
|
// re-determine available if none available now
|
||||||
if (available == 0) {
|
if (available == 0) {
|
||||||
lookahead = _reader.read();
|
|
||||||
if (lookahead == -1) {
|
if (!_isStdError && !_isTerminal){
|
||||||
return null;
|
long lastInput = _timeOfLastInput;
|
||||||
} else {
|
while (lastInput == _timeOfLastInput && _keepRunning){ // once there's something new, we can stop waiting
|
||||||
available = _reader.available() + 1;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue