- Don't turn in libs as submodules.
- Makefile should explicitly name all source files (
make dump_sources
). - Make must compile without relinking
-
make all
shouldn't recompile/rearchive any objects or sources. - Add
.keep
to object dirs - Create non-phony rule for each lib archive
-
- Follows
norminette 3.3.51
- Compiles with workspace's
cc
(clang
version12.0.1
)- Switch Makefile's
clang-12
toCC
before submitting.
- Switch Makefile's
- Compiles with
-Wall -Wextra -Werror
- Makefile rules:
$(NAME)
all
clean
fclean
re
- Should not quit unexpectedly (segmentation fault, bus error, double free, etc.)
- All allocated heap memory properly freed, no memory leaks.
- Use gcc
-fsanitize=leak
flag. - Remove flag before submitting (
readline()
leaks). - Check memory leaks with
valgrind
.
- Use gcc
-
.linux
file (42 Workspaces) - Test in workspaces
- Program name
minishell
- Turn in
Makefile
,*.h
,*.c
,.linux
,.gitignore
- Allowed 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
-
libft
allowed
-
- Not use more than one global variable. Think about it. You will have to explain its purpose.
- Pass all testers
- https://github.com/LucasKuhn/myshell_tester
- Habilitar testes desativados (
pipes_bckp
eredirects_bckp
).
- Habilitar testes desativados (
- https://github.com/LucasKuhn/myshell_tester
- Add
debug()
messages:- Prompt
- Expander
- Lexer
- Syntax Validator
- Trimmer
- Parser
- Executor
- Add
-d
and--debug
flags (./minishell -d
)
- Ler commando do usuário
- Expandir
- Lexar
- Vericar Sintaxe
- Remover Aspas
- Parsear
- Executar
- Repetir
- Adicionar toda memoria do loop (REPL) no
lalloc()
- Prompt
- Expander
- Lexer
- Parser
- Liberar memória antes de sair do loop com
free_lalloc()
- Remover todos os usos de
destroy_parse()
- Liberar histroy do readline com
rl_clear_history()
- Implementar uma Hash Table:
- Implementar uma função criptográfica com poucas colisões (
md5()
). - Calcular o
index
de um elemento a partir da chave. - Inicializar a Hash Table.
- Inicializar um elemento da Hash Table.
- Destruir a Hash Table.
- Destruir elementos da Hash Table (liberar memória).
- Inserir uma variável (chave + valor).
- Recuperar uma variável a partir da chave.
- Deletar uma variável a partir da chave.
- Lidar com colisões (variáveis com o mesmo
index
). - Testar e tratar inputs inválidos (
NULL
table
,key
,value
, etc.) - Inserir array de string.
- Gerar array de strings com todas as variáveis.
- Implementar uma função criptográfica com poucas colisões (
- Definir
envht
. - Inserir
envp
noenvht
na inicialização do shell. - Gerar
envp
a partir doenvht
(para osexecve()
).
- Your shell must implement the following built-ins:
-
echo
with option-n
-
cd
with only a relative or absolute path- Testar caminhos relativos.
- Testar caminhos absolutos.
- Sem argumentos vai para a
HOME
. - Mostrar erro caso tenha mais de 1 argumento.
- Mostrar erro caso o caminho não existe.
- Mostrar erro caso o caminho não seja um diretório.
- Atualizar
PWD
. - Atualizar
OLD_PWD
. - (OPCIONAL)
cd -
te leva ao$OLD_PWD
.
-
pwd
with no options -
export
with no options- Sem argumentos, jogar as variáveis na tela.
- Inserir uma ou mais variáveis.
- Pular variáveis sem atribuição (sem
=
). - Adicionar variável com atribuição e sem valor (
value = ""
). - Verificar variável sem chave com erro.
- Verificar variável vazia com erro.
- Verificar nome de variável com erro.
-
unset
with no options -
env
with no options or arguments- Mostrar erro caso tenha mais de 1 argumento.
-
exit
with no options- Mostrar
exit
. - Se não recebe argumento, utiliza o codigo de saida do último commando (
last_exit
). - Se recebe um argumento, utilizá-lo como código de saida.
- Mostrar erro caso tenha mais de 1 argumento.
- Se o argumento não é um número retornar erro.
- Mostrar
- (OPTIONAL)
help
prints a help message listing all commands
-
- Display a prompt when waiting for a new command.
- Adicionar PS1 (ex:
lgeniole@dev1:~/code/ft/minishell$
):- Nome do usuário.
- Current dir.
- Com
~
.
- Com
- Com cores.
- Have a working history.
- Não adicionar linha vazia (
""
)
- Não adicionar linha vazia (
- Handle
Ctrl-C
,Ctrl-D
andCtrl-\
which should behave like in bash.- In interactive mode:
-
Ctrl-C
displays a new prompt on a new line (SIGINT
signal). -
Ctrl-D
exits the shell (EOF
noSTDIN
). -
Ctrl-\
does nothing (SIGQUIT
signal).
-
- No fork (processo filho):
-
Ctrl-C
(SIGINT
signal). -
Ctrl-D
(EOF
noSTDIN
). -
Ctrl-\
(SIGQUIT
signal).
-
- Criar e utilizar
-
sigemptyset_or_die()
-
sigaction_or_die()
-
rl_on_new_line_or_die()
-
rl_replace_line_or_die()
-
rl_redisplay_or_die()
-
- In interactive mode:
- Handle environment variables (
$
followed by a sequence of characters) which should expand to their values. - Handle
$?
which should expand to the exit status of the most recently executed foreground pipeline.- Adicionar variável
last_exit
aot_minishell
. - Inicializar
$?
com"0"
. - Verificar se a variável é
$?
e inserir-la corretamente.
- Adicionar variável
- Casos:
- Sem variáveis.
- Variável que não existe.
- Variáveis de ambiente.
- Variáveis dentro de aspas simples.
- Variáveis dentro de aspas duplas.
- Variáveis dentro de aspas simples e duplas.
- String vazia.
- Ponteiro nulo.
- (OPCIONAL) Não expandir delimitador de heredoc.
- (OPCIONAL) Expandir
~
para$HOME
(Tilde Expansion).
- Renomear Expansor para Expander
- Not interpret unclosed quotes or special characters which are not required by the subject such as
\
(backslash) or;
(semicolon). - Handle
'
(single quote) which should prevent the shell from interpreting the metacharacters in the quoted sequence. - Handle
"
(double quote) which should prevent the shell from interpreting the metacharacters in the quoted sequence except for$
(dollar sign). - Casos:
- Tokenização simples
- Tokenização com aspas simples
'
- Tokenização com aspas duplas
"
- Tokenização com aspas misturadas
- Tokenização com aspas intercaladas
- Tokenização com aspa avulsa
- Tokenização por pipe
|
- Tokenização por redireção truncada
>
- Tokenização por redireção de entrada
<
- Tokenização por redireção concatenada
>>
- Tokenização por redireção heredoc
<<
- (OPCIONAL) Tokenização por comentário
#
-
t_parse
:- Criar nó para executável.
- Criar nó para pipe.
- Criar nó para truncate.
- Criar nó para append.
- Criar nó para read file.
- Criar nó para heredoc.
-
t_parse_list
:- Criar uma lista linkada onde cada nó é um operador ou um executável.
- Lidar com redirecionamentos intercalados.
- Fix
ft_dlst_addb_lalloc()
andft_dlst_add_lalloc()
.
- Aspas:
- Aspas simples que não fecham.
- Aspas duplas que não fecham.
- Variáveis:
- Nome de variáveis não pode começar com número.
- Nome de variáveis não pode conter metacharacters:
?
,'
,"
,\
,$
,`
,=
,*
,@
,~
,<
,>
,(
,)
,!
,|
,&
,;
,space
,newline
- Nome de arquivo:
- Linux: não pode conter
/
. - Não pode conter characters especias fora de aspas:
|
,;
,`
,(
,)
,!
,!
.
- Linux: não pode conter
- Input do usuário:
- Não pode ter
;
fora de aspas. - Não pode ter
\
fora de aspas. - Não pode ter
>
sem nome do arquivo. - Não pode ter
>>
sem nome do arquivo. - Não pode ter
<
sem nome do arquivo. - Não pode ter
<<
sem delimitador. - Não pode ter
<<
seguido de outro operador:|
,>
,>>
,<
,<<
. - Não pode ter
|
sem próximo commando. - Não pode ter
|
seguido de|
. - Primeiro token não pode ser
|
.
- Não pode ter
- Validar sintaxe dos
char **tokens
- (OPCIONAL) Com mensagens de erro.
- (OPCIONAL) Validar sintaxe da
t_parse_list plist
- Remover aspas para o parser.
- Casos:
- Remover aspas simples
- Remover aspas duplas
- Não remover aspas simples dentro de aspas duplas.
- Não remover aspas duplas dentro de aspas simples.
- Implement pipes (
|
character). The output of each command in the pipeline is connected to the input of the next command via a pipe. - Implement redirections:
-
<
should redirect input. -
>
should redirect output. -
heredoc
:<<
should be given a delimiter, then read the input until a line containing the delimiter is seen. However, it doesn’t have to update the history!- Heredoc roda antes que todos os outros redirecionamentos.
- Resolver os leaks de memória (
hdoc.c
).
-
>>
should redirect output in append mode.
-
- Search and launch the right executable (based on the
PATH
variable or using a relative or an absolute path). - Executar pipe com
fork()
e redirecionamentos. - Testar múltiplos redirecionamentos no mesmo pipe.
- Executar todos os pipes de uma pipeline.
- Testar múltiplos redirecionamentos na mesma pipeline.
- Último pipe é redirecionado para
STDOUT
. - Atualiza o
last_exit
com o exit status do foreground pipeline. - Built-ins:
- Se o commando é um builtin executá-lo antes buscá-lo no sistema.
- Se o commando é um builtin dentro de uma pipeline executá-lo em um
fork()
. - Se o commando é um builtin fora de uma pipeline executá-lo sem
fork()
.- Salvar e restaurar
STDIN
,STDOUT
eSTDERR
no processo principal.
- Salvar e restaurar
- Testar múltiplos redirecionamentos no mesmo builtin.
- Testar múltiplos redirecionamentos na mesma pipeline comm builtins.
- Fechar fds de redirecionamento depois de executar o builtin isolado
- Criar e utilizar
wait_or_die()
waitpid_or_die()
- Executar pipes sem bloquear processos (
forks()
->waits()
)
- Wildcards * should work for the current working directory.
- && and || with parenthesis for priorities.