first commit

This commit is contained in:
Alessandro Mauri 2021-09-13 23:46:17 +02:00
commit 1169a52115
3 changed files with 62 additions and 0 deletions

6
README.md Normal file
View File

@ -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.

8
config.h Normal file
View File

@ -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

48
msh.c Normal file
View File

@ -0,0 +1,48 @@
#include <stdio.h>
#include <stdlib.h>
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)
{
}