Skip to content

hashlyschool/42_minishell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Краткое описание проекта

В данном репозитории содержится реализация простой оболочки для unix-подобных систем, которая является упрощением оболочки bash

Содержание

  • docs - директория содержит файлы, которые описывают задание, а также ссылки на полезные материалы по теме и т.п.
  • project - директория содержит исходные коды и утилиты для сборки проекта
  • .vscode - директория содержит некоторые конфигурационные файлы для разработки в VSCode
  • .gitignore - это файл, который содержит названия неотслеживаемых файлов
  • .gitsubmodules - это файл, который содержит информацию о submodules

Сборка и запуск программы

$git clone --recurse-submodules <URL> <NAME DIR>
$cd <NAME DIR>/project && make && ./minishell

Основной функционал

Основной функционал данной оболочки, в большей степени, соответствует оболочке bash и копирует её поведение, но все-таки имеет серьезные отличия поведение соответствует заданию на проект, который находится в /docs/Readme.md

Разрешенные функции (external functs)

Нажми для раскрытия
Function Description
readline char *readline(const char *prompt); readline returns the text of the line read. A blank line returns the empty string. If EOF is encountered while reading a line, and the line is empty, NULL is returned. If an EOF is read with a non-empty line, it is treated as a newline.
rl_clear_history Function: void rl_clear_history (void); Clear the history list by deleting all of the entries, in the same manner as the History library's clear_history() function. This differs from clear_history because it frees private data Readline saves in the history list.
rl_on_new_line Function: int rl_on_new_line (void); Tell the update functions that we have moved onto a new (empty) line, usually after outputting a newline.
rl_replace_line Function: void rl_replace_line (const char *text, int clear_undo); Replace the contents of rl_line_buffer with text. The point and mark are preserved, if possible. If clear_undo is non-zero, the undo list associated with the current line is cleared.
rl_redisplay Function: void rl_redisplay(void); Change what's displayed on the screen to reflect the current contents of rl_line_buffer.
add_history The add_history calls go further: they add every command typed into the history buffer. With this done, we can now scroll through command history with up/down arrows, and even do history seaches with Ctrl+R.
printf The functions in the printf() family produce output according to a format as described to link.
malloc The malloc() function allocates size bytes and returns a pointer to the allocated memory.
write 😏
access int access(const char *pathname, int mode); access() checks whether the calling process can access the file pathname. If pathname is a symbolic link, it is dereferenced.
open 😏
read 😏
fork 😏
wait 😏
waitpid 😏
wait3 The wait3() and wait4() system calls are similar to waitpid(2), but additionally return resource usage information about the child in the structure pointed to by rusage.
wait4 The wait3() and wait4() system calls are similar to waitpid(2), but additionally return resource usage information about the child in the structure pointed to by rusage.
signal 😏
sigaction 😏
kill 😏
exit 😏
getcwd char *getcwd(char *buf, size_t size); These functions return a null-terminated string containing an absolute pathname that is the current working directory of the calling process.
chdir 😏
stat int stat(const char *path, struct stat *buf); These functions return information about a file.
lstat int lstat(const char *path, struct stat *buf); These functions return information about a file.
fstat int fstat(int fd, struct stat *buf); These functions return information about a file.
unlink unlink() deletes a name from the file system. If that name was the last link to a file and no processes have the file open the file is deleted and the space it was using is made available for reuse.
execve int execve(const char *filename, char *const argv[],char *const envp[]); execve() executes the program pointed to by filename. filename must be either a binary executable, or a script
dup int dup(int oldfd); These system calls create a copy of the file descriptor oldfd. dup() uses the lowest-numbered unused descriptor for the new descriptor.
dup2 int dup2(int oldfd, int newfd); These system calls create a copy of the file descriptor oldfd. dup2() makes newfd be the copy of oldfd, closing newfd first if necessary.
pipe int pipe(int pipefd[2]); pipe() creates a pipe, a unidirectional data channel that can be used for interprocess communication.
opendir DIR *opendir(const char *name); The opendir() function opens a directory stream corresponding to the directory name, and returns a pointer to the directory stream.
readdir int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result); The readdir() function returns a pointer to a dirent structure representing the next directory entry in the directory stream pointed to by dirp. It returns NULL on reaching the end of the directory stream or if an error occurred.
closedir int closedir(DIR *dirp); The closedir() function closes the directory stream associated with dirp. A successful call to closedir() also closes the underlying file descripotr associated with dirp.
strerror char *strerror(int errnum); The strerror() function returns a string describing the error code passed in the argument errnum
perror void perror(const char *s); The routine perror() produces a message on the standard error output, describing the last error encountered during a call to a system or library function.
isatty int isatty(int desc); returns 1 if desc is an open file descriptor connected to a terminal and 0 otherwise.
ttyname char *ttyname(int fd); The function ttyname() returns a pointer to the null-terminated pathname of the terminal device that is open on the file descriptor fd, or NULL on error (for example, if fd is not connected to a terminal).
ttyslot int ttyslot(void); The legacy function ttyslot() returns the index of the current user's entry in some file.
ioctl int ioctl(int d, int request, ...); The ioctl() function manipulates the underlying device parameters of special files.
getenv char *getenv(const char *name); The getenv() function searches the environment list to find the environment variable name, and returns a pointer to the corresponding value string.
tcsetattr int tcsetattr(int fd, int optional_actions, const struct termios *termios_p); tcsetattr() sets the parameters associated with the terminal (unless support is required from the underlying hardware that is not available) from the termios structure referred to by termios_p
tcgetattr int tcgetattr(int fd, struct termios *termios_p); tcgetattr() gets the parameters associated with the object referred by fd and stores them in the termios structure referenced by termios_p. This function may be invoked from a background process; however, the terminal attributes may be subsequently changed by a foreground process.
tgetent int tgetent(char *bp, const char *name); The tgetent() function looks up the termcap entry for name. The emulation ignores the buffer pointer bp.
tgetflag int tgetflag(char id[2]); The tgetflag() function gets the Boolean entry for id.
tgetnum int tgetnum(char id[2]); The tgetnum() function gets the numeric entry for id.
tgetstr char *tgetstr(char id[2], char **area); The tgetstr() function gets the string entry for id. If area is not a null pointer and does not point to a null pointer, tgetstr() copies the string entry into the buffer pointed to by *area and advances the variable pointed to by area to the first byte after the copy of the string entry.
tgoto char *tgoto(const char *cap, int col, int row); The tgoto routine instantiates the parameters into the given capability. The output from this routine is to be passed to tputs.
tputs int tputs(const char *str, int affcnt, int (*putc)(int)); The tputs routine is described on the curs_terminfo(3X) manual page. It can retrieve capabilities by either termcap or terminfo name.

🐚