-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathA1.cpp
More file actions
67 lines (57 loc) · 1.6 KB
/
A1.cpp
File metadata and controls
67 lines (57 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "toyshell.h"
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
ToyShell shell;
string command;
bool alias = true;
int status=0;
shell.aliasSizeX=0;
shell.jobSize=0;
shell.jobStored=1;
shell.jobLimit=10;
int found =0;
//Loop until command STOP or corresponding alias is entered
do{
//Prompt
cout<< shell.name<<"["<<shell.count<<"]"<<shell.terminator;
getline(cin, command);
//find if any comments are in string
found = command.find('$');
if(found >=0){ //omit any text after comment
if(found==0 )
command="";
else
command = command.substr(0,found);
}
if(!command.empty()){
//shell.original = command;
shell.tokenize(command);
alias = true;
//check if command is alias
//if no more aliases are found variable is set to false;
do{
alias = shell.alias();
}while(alias);
//Execute Command
status = shell.execute();
if(status==10){
cout << "Stopping Shell" << endl;
break;
}
//if anything but 0 is returned, call function to write out error message
/*if(!status)
cout<<shell.errorMessage(status)<<endl;
*/
//Save command to History
shell.saveHistory();
//increase command count
shell.increaseCount();
shell.pScriptName = "";
shell.scriptName = "";
}
}while(status != 10);
return 0;
}