Alicia-bites / minishell

This project is about creating a simple shell.
1 stars 0 forks source link

minishell

This project is about creating a simple shell. Well it's not that simple!

How to use

Team name

SMBASH

Contributors

Content

Historic :clock7:

Go to content Date YYYY-MM-DD Description
2022-06-17 methodology alignment
2022-06-15 init README

ToDo :dart:

Go to content

ToDo (officiO)

:warning: The readline() function can cause memory leaks. You don’t have to fix them. But that doesn’t mean your own code, yes the code you wrote, can have memory leaks.

Env

The command allows you to run another program in a custom environment without modifying the current one. When used without an argument it will print a list of the current environment variables.

:warning The command will change the env list only for the active command no matters if several pipes

:pushpin: Normal behaviour of env process if pipe due to fork which duplicates the vqriqbles before to execute the commqnd

Syntax

env
env ENV_NAME=value
env ENV_NAME=value <command>

Rules

  1. If no ENV_NAME ==> Display env list as following ENV_NAME=value
  2. If ENV_NAME is specified and already existing in env list, always store its value ==>
  3. ENV_NAME must start by [a-z;A-Z;0-9;_;@] ==> To be confirmed on LINUX system
  4. ENV_NAME must finish by [a-z;A-Z;0-9;_;@;-] ==> To be confirmed on LINUX system
  5. ENV_NAME can have escape character [\;-;+] ==> To be confirmed on LINUX system
  6. ENV_NAME can have expansion process
    export antho=cia
    export al$antho=tata
    env | sort | grep 'al'
    alicia=tata
  7. ENV_NAME value can be appended by using expansion process and only with field separator [@-:.,]
  8. If ENV_NAME is specified and already existing in env list, always reetore its original value (see step 2)

:warning: ENV_NAME is case sensitive
:warning: append existing variable which does not exist will create it only during the flow of command if command argument exists

Export

The command sets environment variables.

:warning The command will change the env list only for the active command only if several pipes. Otherwise the env list is changed

:pushpin: Normal behaviour of export process if pipe due to fork which duplicates the vqriqbles before to execute the commqnd

Example: export ANTHO=tata ==> will update/create the env AMTHO into the env list export ANTHO=tata | echo $ANTHO ==> will update/create the env ANTHO only for the active command

Syntax

export
export ENV_NAME=value
export ENV_NAME=$EXISTING_ENV:value

Rules

  1. If no ENV_NAME ==> Display env list as following declare -x ENV_NAME=value
  2. ENV_NAME must start by [a-z;A-Z;_]
  3. ENV_NAME must finish by [a-z;A-Z;0-9;_]
  4. ENV_NAME can have escape character [\]
  5. ENV_NAME can have expansion process
    export antho=cia
    export al$antho=tata
    env | sort | grep 'al'
    alicia=tata
  6. ENV_NAME value can be appended by using expansion process and only with field separator [@-:.,]

:warning: ENV_NAME is case sensitive
:warning: append existing variable which does not exist will create it

Externals functions

readline, rl_clear_history, rl_on_new_line,
rl_replace_line, rl_redisplay, add_history,
printf, malloc, free, write, access, open, read,
close, fork, wait, waitpid, wait3, wait4, signal,
sigaction, sigemptyset, sigaddset, kill, exit,
getcwd, chdir, stat, lstat, fstat, unlink, execve,
dup, dup2, pipe, opendir, readdir, closedir,
strerror, perror, isatty, ttyname, ttyslot, ioctl,
getenv, tcsetattr, tcgetattr, tgetent, tgetflag,
tgetnum, tgetstr, tgoto, tputs

readline

:mag: To learn

rl_clear_history

:mag: To learn

rl_on_new_line

:mag: To learn

rl_replace_line

:mag: To learn

rl_redisplay

:mag: To learn

add_history

:mag: To learn

printf

:mag: To learn

malloc

:mag: To learn

free

:mag: To learn

write

:mag: To learn

access

:mag: Use to check permission right on object (files/directory) :video_game: pipex Link

open

:mag: To learn

read

:mag: To learn

close

:mag: To learn

fork

:mag: Use to clone the active process to a child process :video_game: pipex Link

wait

:mag: Use to wait a specific process :video_game: pipex Link

waitpid

:mag: Use to wait a specific process :video_game: pipex Link

wait3

:mag: Obsolete

wait4

:mag: Obsolete

signal

:mag: Overview of signals Link

sigaction

:mag: Examine and change a signal action Link

sigemptyset

:mag: Initialize and empty a signal set Link

sigaddset

:mag: Add a signal to a signal set Link

kill

:mag: To learn

exit

:mag: To learn

getcwd

:mag: To learn

chdir

:mag: To learn

stat

:mag: To learn

lstat

:mag: To learn

fstat

:mag: To learn

unlink

:mag: To learn

execve

:mag: Use to execute a command :video_game: pipex

dup

:mag: Use to create a new file descriptor according to an existing one :video_game: pipex

dup2

:mag: Use to "replace" an existing file descriptor from another existing one :video_game: pipex

pipe

:mag: Use to create two new file descriptor which can communicate through different process :video_game: pipex

opendir

:mag: To learn

readir

:mag: To learn

closedir

:mag: To learn

strerror

:mag: To learn

perror

:mag: To learn

isatty

:mag: Test whether a file descriptor refers to a terminal

ttyname

:mag: Return name of a terminal

ttyslot

:mag: Find the slot of the current user's terminal in some file

ioctl

:mag: Control device. To learn

getenv

:mag: Get an environment variable

tcsetattr

:mag: Set the parameters associated with the terminal Link

tcgetattr

:mag: Get the parameters associated with the terminal Link

tgetent

:mag: To learn -->WTF ?

tgetflag

:mag: To learn -->WTF ?

tgetnum

:mag: To learn -->WTF ?

tgetstr

:mag: To learn -->WTF ?

tgoto

:mag: To learn -->WTF ?

tputs

:mag: To learn -->WTF ?

Sources :link:

Go to content

Bash

Builtins

Export

Git

Parser

Shell

Signal