Userspace: Start work on shell
This commit is contained in:
parent
9e0abbc2f0
commit
0ab3332ad3
|
@ -180,7 +180,7 @@ static void init2(void* tty1)
|
|||
|
||||
((TTY*)tty1)->initialize_device();
|
||||
|
||||
MUST(Process::create_userspace("/usr/bin/cat"sv));
|
||||
MUST(Process::create_userspace("/usr/bin/Shell"sv));
|
||||
return;
|
||||
|
||||
Process::create_kernel(
|
||||
|
|
|
@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.26)
|
|||
project(userspace CXX)
|
||||
|
||||
set(USERSPACE_PROJECTS
|
||||
Shell
|
||||
cat
|
||||
test
|
||||
yes
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
cmake_minimum_required(VERSION 3.26)
|
||||
|
||||
project(Shell CXX)
|
||||
|
||||
set(SOURCES
|
||||
main.cpp
|
||||
)
|
||||
|
||||
add_executable(Shell ${SOURCES})
|
||||
target_compile_options(Shell PUBLIC -O2 -g)
|
||||
add_dependencies(Shell libc-install)
|
||||
target_link_options(Shell PUBLIC -nodefaultlibs)
|
||||
target_link_libraries(Shell PUBLIC ${BANAN_LIB}/libc.a)
|
||||
|
||||
add_custom_target(Shell-install
|
||||
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/Shell ${BANAN_BIN}/
|
||||
DEPENDS Shell
|
||||
)
|
|
@ -0,0 +1,27 @@
|
|||
#include <stdio.h>
|
||||
#include <termios.h>
|
||||
|
||||
struct termios old_termios, new_termios;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
for (int i = 0; i < argc; i++)
|
||||
printf("%s\n", argv[i]);
|
||||
|
||||
tcgetattr(0, &old_termios);
|
||||
|
||||
new_termios = old_termios;
|
||||
new_termios.c_lflag &= ~(ECHO | ICANON);
|
||||
tcsetattr(0, TCSANOW, &new_termios);
|
||||
|
||||
while (true)
|
||||
{
|
||||
char c;
|
||||
fread(&c, 1, sizeof(char), stdin);
|
||||
fputc(c, stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
tcsetattr(0, TCSANOW, &old_termios);
|
||||
return 0;
|
||||
}
|
|
@ -21,10 +21,6 @@ int main(int argc, char** argv)
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
printf("argc %d, argv %p\n", argc, argv);
|
||||
for (int i = 0; i < argc; i++)
|
||||
printf("%s\n", argv[i]);
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
for (int i = 1; i < argc; i++)
|
||||
|
|
Loading…
Reference in New Issue