Write a shell.
A shell is a program which executes commands from a string given by a prompt.
A prompt is the concept where your program waits for an input, in this case your prompt will have to wait for STDIN
to have some char *
input from the user on the terminal (a tty
).
You can use your get_next_line
and implement it to make it work as The GNU Readline Library or you can simply include this lib for Mac or use it for Linux.
You could simply download the readline-master.tar.gz, compile it and link it to your binary. But this is not the correct way to do it. Your project should only contain code made by your self not third-party code. Given that principle, we'll make our project download it, descompress it, compile it and link it as following.
$(READLINE_LIB): | $(READLINE_DIR)
printf "$(BLUE)Compiling and linking library...$(DEF_COLOR)\n"
$(MAKE) -s --no-print-directory -C $(READLINE_DIR) >>$(LOG) 2>&1
printf "$(GREEN)\r\033[2K[✓] $(PINK)readline$(GREEN) created!!!$(DEF_COLOR)\n\n"
$(READLINE_DIR):
printf "$(CYAN)Downloading: $(PINK)readline...$(DEF_COLOR)\n"
cd lib; curl -s -O http://git.savannah.gnu.org/cgit/readline.git/snapshot/readline-master.tar.gz
rm -rf $(READLINE_DIR)
mkdir -p $(READLINE_DIR)
tar -xpf lib/readline-master.tar.gz -C $(READLINE_DIR) --strip-components 1
rm -rf lib/readline-master.tar.gz
printf "$(CYAN)Configuring: $(PINK)readline...$(DEF_COLOR)\n"
cd $(READLINE_DIR); bash ./configure >>$(LOG) 2>&1
- check syntax ->
lexer
- tokenize ->
tokenizer
- expanse args and redirections ->
expansor
- execute ->
executor
norminette src inc lib/libft
make test
make mpanic