first commit

master
Alessandro Mauri 3 years ago
commit 1169a52115
  1. 6
      README.md
  2. 8
      config.h
  3. 48
      msh.c

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

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

@ -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)
{
}