File tree Expand file tree Collapse file tree 2 files changed +6
-31
lines changed
Expand file tree Collapse file tree 2 files changed +6
-31
lines changed Original file line number Diff line number Diff line change @@ -9,3 +9,5 @@ set(CMAKE_CXX_STANDARD 23) # Enable the C++23 standard
99add_executable (shell ${SOURCE_FILES} )
1010
1111target_link_libraries (shell PRIVATE readline )
12+
13+ include_directories (src )
Original file line number Diff line number Diff line change 1- #include < iostream>
2- #include < string>
3-
4- void do_exit (std::string args) {
5- int exit_code = std::stoi (args);
6- exit (exit_code);
7- }
8-
9- void do_echo (std::string args) {
10- std::cout << args << std::endl;
11- }
1+ #include " shell.h"
122
133int main () {
14- // Flush after every std::cout / std:cerr
15- std::cout << std::unitbuf;
16- std::cerr << std::unitbuf;
17-
18- std::string input;
19- do {
20- std::cout << " $ " ;
21- std::getline (std::cin, input);
22- std::string cmd = input.substr (0 , input.find (' ' ));
23- std::string args = input.substr (input.find (' ' ) + 1 );
24- if (cmd == " exit" ) {
25- do_exit (args);
26- }
27- else if (cmd == " echo" ) {
28- do_echo (args);
29- }
30- else if (input != " " ) {
31- std::cout << input << " : command not found" << std::endl;
32- }
33- } while (input != " " );
4+ Shell shell;
5+ shell.run ();
6+ return 0 ;
347}
You can’t perform that action at this time.
0 commit comments