fix readme

This commit is contained in:
Quinten Mennen 2025-02-06 16:15:59 +01:00
parent 75cbe896ce
commit 43583e5795
3 changed files with 207 additions and 139 deletions

216
README.md
View File

@ -1,38 +1,59 @@
# Minishell # Minishell
======= A lot of amazing shell stuff
## Dependencies ## Dependencies
- libreadline-dev - libreadline-dev
- libncurses-dev - libncurses-dev
## merge info ## TODO
origen/quinten -> willem: - Find absolute path for command input ('/', './', 'cmd')
- Add heredoc to tokenizer
ik het TokenType veranderd naar t_token_type vanwege de norm - Environment to `t_list`
- Get environment array (export)
Volgens mij had je een off-by-one error in ft_lexer_readword:85 - Preliminary signals
je moet de null terminator ook meerekenen in de malloc size - Define struct for commands, something like (
```c ```c
if (!(word = malloc(sizeof(char) * (i + 1)))) typedef struct s_command
{
char *command;
char *path;
char **args;
int fd_in;
int fd_out;
} t_command;
``` ```
)
- Make the `executor`, run a command
- Make a parser to create a command list
- Add redirects, appends, pipe etc. File descriptor functions
- Expand \$ vars & support \$?
- __Bonus:__ Command tree for &&, ||, *
## Allowed Functions ## Allowed Functions
### `<fcntl.h>` ### `<readline/readline.h>`
* `open` * `readline`
* `int open(const char *pathname, int flags, ...);` * `char *readline(const char *prompt);`
* Opens a file specified by pathname. The flags argument determines the file access mode and file status flags. * Reads a line from the terminal with editing capabilities.
* `rl_clear_history`
* `void rl_clear_history(void);`
* Clears the history of lines read by readline.
* `rl_on_new_line`
* `int rl_on_new_line(void);`
* Resets the state to indicate that a new line of input is being read.
* `rl_replace_line`
* `int rl_replace_line(const char *text, int clear_undo);`
* Replaces the contents of the current line with text.
* `rl_redisplay`
* `int rl_redisplay(void);`
* Redisplays the current input line.
* `add_history`
* `void add_history(const char *line);`
* Adds the line to the history list.
### `<dirent.h>` ### `<stdio.h>`
* `opendir` * `printf`
* `DIR *opendir(const char *name);` * `int printf(const char *format, ...);`
* Opens a directory stream corresponding to the directory name, and returns a pointer to the directory stream. * Sends formatted output to stdout.
* `readdir`
* `struct dirent *readdir(DIR *dirp);`
* Reads the next directory entry from the directory stream pointed to by dirp.
* `closedir`
* `int closedir(DIR *dirp);`
* Closes the directory stream associated with dirp.
### `<stdlib.h>` ### `<stdlib.h>`
* `malloc` * `malloc`
@ -42,21 +63,25 @@ je moet de null terminator ook meerekenen in de malloc size
* `void free(void *ptr);` * `void free(void *ptr);`
* Frees the memory space pointed to by ptr, which must have been returned by a previous call to malloc. * Frees the memory space pointed to by ptr, which must have been returned by a previous call to malloc.
### `<stdio.h>` ### `<unistd.h>`
* `printf` * `write`
* `int printf(const char *format, ...);` * `ssize_t write(int fd, const void *buf, size_t count);`
* Sends formatted output to stdout. * Writes up to count bytes from the buffer starting at buf to the file referred to by the file descriptor fd.
* `access`
### `<sys/stat.h>` * `int access(const char *pathname, int mode);`
* `stat` * Checks the file named by pathname for accessibility according to the bit pattern contained in mode.
* `int stat(const char *pathname, struct stat *statbuf);` * `open`
* Retrieves information about the file pointed to by pathname and fills in the stat structure. * `int open(const char *pathname, int flags, ...);`
* `lstat` * Opens a file specified by pathname. The flags argument determines the file access mode and file status flags.
* `int lstat(const char *pathname, struct stat *statbuf);` * `read`
* Similar to stat, but does not follow symbolic links. * `ssize_t read(int fd, void *buf, size_t count);`
* `fstat` * Reads up to count bytes from file descriptor fd into the buffer starting at buf.
* `int fstat(int fd, struct stat *statbuf);` * `close`
* Retrieves information about the file referred to by the open file descriptor fd. * `int close(int fd);`
* Closes the file descriptor fd.
* `fork`
* `pid_t fork(void);`
* Creates a new process by duplicating the calling process.
### `<sys/wait.h>` ### `<sys/wait.h>`
* `wait` * `wait`
@ -89,42 +114,84 @@ je moet de null terminator ook meerekenen in de malloc size
* `int kill(pid_t pid, int sig);` * `int kill(pid_t pid, int sig);`
* Sends the signal sig to the process specified by pid. * Sends the signal sig to the process specified by pid.
### `<unistd.h>` ### `<stdlib.h>`
* `write` * `exit`
* `ssize_t write(int fd, const void *buf, size_t count);` * `void exit(int status);`
* Writes up to count bytes from the buffer starting at buf to the file referred to by the file descriptor fd. * Causes normal process termination and returns an exit status to the host environment.
* `access`
* `int access(const char *pathname, int mode);`
* Checks the file named by pathname for accessibility according to the bit pattern contained in mode.
* `read`
* `ssize_t read(int fd, void *buf, size_t count);`
* Reads up to count bytes from file descriptor fd into the buffer starting at buf.
* `close`
* `int close(int fd);`q
* Closes the file descriptor fd.
* `fork`
* `pid_t fork(void);`
* Creates a new process by duplicating the calling process.
### `<readline/readline.h>` ### `<sys/stat.h>`
* `readline` * `stat`
* `char *readline(const char *prompt);` * `int stat(const char *pathname, struct stat *statbuf);`
* Reads a line from the terminal with editing capabilities. * Retrieves information about the file pointed to by pathname and fills in the stat structure.
* `rl_clear_history` * `lstat`
* `void rl_clear_history(void);` * `int lstat(const char *pathname, struct stat *statbuf);`
* Clears the history of lines read by readline. * Similar to stat, but does not follow symbolic links.
* `rl_on_new_line` * `fstat`
* `int rl_on_new_line(void);` * `int fstat(int fd, struct stat *statbuf);`
* Resets the state to indicate that a new line of input is being read. * Retrieves information about the file referred to by the open file descriptor fd.
* `rl_replace_line`
* `int rl_replace_line(const char *text, int clear_undo);` ### `<unistd.h>`
* Replaces the contents of the current line with text. * `unlink`
* `rl_redisplay` * `int unlink(const char *pathname);`
* `int rl_redisplay(void);` * Deletes a name from the filesystem.
* Redisplays the current input line. * `pipe`
* `add_history` * `int pipe(int pipefd[2]);`
* `void add_history(const char *line);` * Creates a pipe, a unidirectional data channel that can be used for interprocess communication.
* Adds the line to the history list. * `dup`
* `int dup(int oldfd);`
* Duplicates the file descriptor oldfd.
* `dup2`
* `int dup2(int oldfd, int newfd);`
* Duplicates oldfd to newfd, closing newfd first if necessary.
* `execve`
* `int execve(const char *pathname, char *const argv[], char *const envp[]);`
* Executes the program referred to by pathname.
* `getcwd`
* `char *getcwd(char *buf, size_t size);`
* Gets the current working directory and stores it in the buffer pointed to by buf.
* `chdir`
* `int chdir(const char *path);`
* Changes the current working directory to the directory specified in path.
### `<dirent.h>`
* `opendir`
* `DIR *opendir(const char *name);`
* Opens a directory stream corresponding to the directory name, and returns a pointer to the directory stream.
* `readdir`
* `struct dirent *readdir(DIR *dirp);`
* Reads the next directory entry from the directory stream pointed to by dirp.
* `closedir`
* `int closedir(DIR *dirp);`
* Closes the directory stream associated with dirp.
### `<string.h>`
* `strerror`
* `char *strerror(int errnum);`
* Returns a pointer to the textual representation of the error number errnum.
* `perror`
* `void perror(const char *s);`
* Prints a descriptive error message to stderr.
### `<unistd.h>`
* `isatty`
* `int isatty(int fd);`
* Tests whether fd is an open file descriptor referring to a terminal.
* `ttyname`
* `char *ttyname(int fd);`
* Returns a pointer to the null-terminated pathname of the terminal associated with fd.
* `ttyslot`
* `int ttyslot(void);`
* Returns the index of the current user's terminal in the user accounting file.
### `<sys/ioctl.h>`
* `ioctl`
* `int ioctl(int fd, unsigned long request, ...);`
* Manipulates the underlying device parameters of special files.
### `<stdlib.h>`
* `getenv`
* `char *getenv(const char *name);`
* Searches the environment list for a string that matches the name.
### `<termios.h>` ### `<termios.h>`
* `tcsetattr` * `tcsetattr`
@ -153,3 +220,4 @@ je moet de null terminator ook meerekenen in de malloc size
* `tputs` * `tputs`
* `int tputs(const char *str, int affcnt, int (*putc)(int));` * `int tputs(const char *str, int affcnt, int (*putc)(int));`
* Outputs the string str with padding. * Outputs the string str with padding.

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* :::::::: */ /* ::: :::::::: */
/* allowed.h :+: :+: */ /* allowed.h :+: :+: :+: */
/* +:+ */ /* +:+ +:+ +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/04 16:13:11 by whaffman #+# #+# */ /* Created: 2025/02/04 16:13:11 by whaffman #+# #+# */
/* Updated: 2025/02/04 16:13:12 by whaffman ######## odam.nl */ /* Updated: 2025/02/06 16:14:44 by qmennen ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,12 +19,12 @@
# include <string.h> # include <string.h>
# include <sys/types.h> # include <sys/types.h>
# include <sys/wait.h> # include <sys/wait.h>
# include <sys/stat.h>
# include <sys/ioctl.h>
# include <fcntl.h> # include <fcntl.h>
# include <errno.h> # include <errno.h>
# include <signal.h> # include <signal.h>
# include <dirent.h> # include <dirent.h>
# include <sys/stat.h>
# include <sys/ioctl.h>
# include <termios.h> # include <termios.h>
# include <term.h> # include <term.h>

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* :::::::: */ /* ::: :::::::: */
/* prompt.c :+: :+: */ /* prompt.c :+: :+: :+: */
/* +:+ */ /* +:+ +:+ +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/04 16:13:08 by whaffman #+# #+# */ /* Created: 2025/02/04 16:13:08 by whaffman #+# #+# */
/* Updated: 2025/02/05 17:05:12 by whaffman ######## odam.nl */ /* Updated: 2025/02/06 16:12:02 by qmennen ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */