From 1169a5211568a2c1094ea7b4a965678938143b97 Mon Sep 17 00:00:00 2001 From: Alessandro Mauri Date: Mon, 13 Sep 2021 23:46:17 +0200 Subject: [PATCH] first commit --- README.md | 6 ++++++ config.h | 8 ++++++++ msh.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 README.md create mode 100644 config.h create mode 100644 msh.c diff --git a/README.md b/README.md new file mode 100644 index 0000000..9d262a9 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# Modular SHell + +A POSIX compliant shell with few additions, modular and hackable source code. + +Built like busybox each component has its source file keeping everything +clean and tidy. \ No newline at end of file diff --git a/config.h b/config.h new file mode 100644 index 0000000..3ebec85 --- /dev/null +++ b/config.h @@ -0,0 +1,8 @@ +#ifndef MSH_CONFIG_H +#define MSH_CONFIG_H + +#define DEF_HISTSIZE 512 +#define DEF_HISTPATH ".history" +#define DEF_SHELLRC ".mshrc" + +#endif \ No newline at end of file diff --git a/msh.c b/msh.c new file mode 100644 index 0000000..3419df1 --- /dev/null +++ b/msh.c @@ -0,0 +1,48 @@ +#include +#include + +char *PS1 = NULL; +unsigned int histsize = DEF_HISTSIZE; + +// Buffered user data +struct { + char *name; + char *home; + uid_t uid; + gid_t gid; +} uinfo; + +void sh_fill_uinfo(void); +void sh_update_ps1(void); +inline void sh_print_ps1(void); + +int main(int argc, char **argv) +{ + sh_fill_uinfo(); + + for (;;) { + sh_update_ps1(); + sh_print_ps1(); + } + + return EXIT_SUCCESS; +} + +void sh_fill_uinfo(void) +{ + struct pwuid pw; + uinfo.uid = getuid(); + uidfo.gid = getgid(); + +} + +inline void sh_print_ps1(void) +{ + puts(PS1); + putchar(' '); +} + +void sh_update_ps1(void) +{ + +} \ No newline at end of file