fix backspace bug

This commit is contained in:
Victoria Jeffrey 2016-10-05 22:44:39 -04:00 committed by Dominik Richter
parent e6c390178a
commit ab38319e3b
2 changed files with 8 additions and 5 deletions

View file

@ -105,6 +105,7 @@ export class AppComponent implements OnInit {
// if it matches, we set matchFound to true and call printOnStdout. if it doesn't match,
// we display a default error message
execCommand(command, shell) {
command = command.replace(/\r/g,'');
let response = ''
let dir = 'app/responses/';
let cmd = command.replace(/ /g,'\\s*')
@ -126,7 +127,7 @@ export class AppComponent implements OnInit {
// respond with 'invalid command' and the command entered
if (matchFound === false) {
if (command.match(/^inspec exec\s*.*/)) {
let target = command.match(/^inspec exec\s*(.*)/)
let target = command.match(/^inspec exec\s*(.*)/);
response = this.red + "Could not fetch inspec profile in '" + target[1] + "' " + this.black;
} else {
response = this.red + 'command not found: ' + command;

View file

@ -149,7 +149,7 @@ export class XtermTerminalComponent implements OnInit, OnChanges{
// stores a command in commmand history
storeInHistory(cmd) {
// remove cariage returns from history commands
cmd = cmd.replace(/\r/,'')
cmd = cmd.replace(/\r/,'');
this.history.push(cmd);
this.historyIndex = this.history.length
}
@ -162,13 +162,15 @@ export class XtermTerminalComponent implements OnInit, OnChanges{
// reprint a command in the current line
reprintCommand(cmd){
this.term.write(this.clearLine+this.prompt + cmd)
// strip out any extra \r characters
cmd = cmd.replace(/\r/g,'');
this.term.write(this.clearLine + this.prompt + cmd);
}
// resets the terminal
clear() {
this.term.reset()
this.writePrompt()
this.term.reset();
this.writePrompt();
}
// terminal event handler