mirror of
https://github.com/inspec/inspec
synced 2024-11-27 07:00:39 +00:00
fix backspace bug
This commit is contained in:
parent
e6c390178a
commit
ab38319e3b
2 changed files with 8 additions and 5 deletions
|
@ -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,
|
// if it matches, we set matchFound to true and call printOnStdout. if it doesn't match,
|
||||||
// we display a default error message
|
// we display a default error message
|
||||||
execCommand(command, shell) {
|
execCommand(command, shell) {
|
||||||
|
command = command.replace(/\r/g,'');
|
||||||
let response = ''
|
let response = ''
|
||||||
let dir = 'app/responses/';
|
let dir = 'app/responses/';
|
||||||
let cmd = command.replace(/ /g,'\\s*')
|
let cmd = command.replace(/ /g,'\\s*')
|
||||||
|
@ -126,7 +127,7 @@ export class AppComponent implements OnInit {
|
||||||
// respond with 'invalid command' and the command entered
|
// respond with 'invalid command' and the command entered
|
||||||
if (matchFound === false) {
|
if (matchFound === false) {
|
||||||
if (command.match(/^inspec exec\s*.*/)) {
|
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;
|
response = this.red + "Could not fetch inspec profile in '" + target[1] + "' " + this.black;
|
||||||
} else {
|
} else {
|
||||||
response = this.red + 'command not found: ' + command;
|
response = this.red + 'command not found: ' + command;
|
||||||
|
|
|
@ -149,7 +149,7 @@ export class XtermTerminalComponent implements OnInit, OnChanges{
|
||||||
// stores a command in commmand history
|
// stores a command in commmand history
|
||||||
storeInHistory(cmd) {
|
storeInHistory(cmd) {
|
||||||
// remove cariage returns from history commands
|
// remove cariage returns from history commands
|
||||||
cmd = cmd.replace(/\r/,'')
|
cmd = cmd.replace(/\r/,'');
|
||||||
this.history.push(cmd);
|
this.history.push(cmd);
|
||||||
this.historyIndex = this.history.length
|
this.historyIndex = this.history.length
|
||||||
}
|
}
|
||||||
|
@ -162,13 +162,15 @@ export class XtermTerminalComponent implements OnInit, OnChanges{
|
||||||
|
|
||||||
// reprint a command in the current line
|
// reprint a command in the current line
|
||||||
reprintCommand(cmd){
|
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
|
// resets the terminal
|
||||||
clear() {
|
clear() {
|
||||||
this.term.reset()
|
this.term.reset();
|
||||||
this.writePrompt()
|
this.writePrompt();
|
||||||
}
|
}
|
||||||
|
|
||||||
// terminal event handler
|
// terminal event handler
|
||||||
|
|
Loading…
Reference in a new issue