chore: add operational notes and test shell source
This commit is contained in:
parent
84c3345595
commit
e8b58f375a
|
|
@ -0,0 +1,33 @@
|
||||||
|
// Minimal test shell to verify the execution environment
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
extern int write(int fd, const void *buf, size_t count);
|
||||||
|
extern int read(int fd, void *buf, size_t count);
|
||||||
|
|
||||||
|
int main(int argc, char *argv[], char *envp[]) {
|
||||||
|
const char *prompt = "shell> ";
|
||||||
|
char buf[128];
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
// Print prompt
|
||||||
|
write(1, prompt, 7);
|
||||||
|
|
||||||
|
// Read command
|
||||||
|
int n = read(0, buf, sizeof(buf) - 1);
|
||||||
|
if (n <= 0) continue;
|
||||||
|
|
||||||
|
buf[n] = '\0';
|
||||||
|
|
||||||
|
// Echo back
|
||||||
|
write(1, "You typed: ", 11);
|
||||||
|
write(1, buf, n);
|
||||||
|
|
||||||
|
// Check for exit
|
||||||
|
if (buf[0] == 'q' && buf[1] == '\n') {
|
||||||
|
write(1, "Goodbye!\n", 9);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue