Created allowed.txt to track allowed functions for minishell and updated AGENTS.md to tell codex to not use any forbidden functions, also updated AGENTS.md to add all builtins changes
This commit is contained in:
13
AGENTS.md
13
AGENTS.md
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## Project Structure & Module Organization
|
## Project Structure & Module Organization
|
||||||
- `src/` holds the shell implementation, with submodules for `builtins/`, `executor/`, `parser/`, and `variables/`.
|
- `src/` holds the shell implementation, with submodules for `builtins/`, `executor/`, `parser/`, and `variables/`.
|
||||||
|
- `src/builtins/` currently includes: `cd`, `echo`, `env`, `exit`, `export`, `pwd`, `unset`.
|
||||||
- `include/` contains public headers used across modules.
|
- `include/` contains public headers used across modules.
|
||||||
- `lib/` is populated at build time with third-party 42 libraries (libft, get_next_line, ft_printf, ft_args).
|
- `lib/` is populated at build time with third-party 42 libraries (libft, get_next_line, ft_printf, ft_args).
|
||||||
- `docs/` stores project references and manual test notes (see `docs/tests.md`).
|
- `docs/` stores project references and manual test notes (see `docs/tests.md`).
|
||||||
@@ -19,11 +20,23 @@
|
|||||||
- The codebase follows 42 **Norminette v4** rules. Run `norminette *.c *.h` (or on specific files) before submitting changes.
|
- The codebase follows 42 **Norminette v4** rules. Run `norminette *.c *.h` (or on specific files) before submitting changes.
|
||||||
- Keep file names lowercase with underscores (e.g., `src/builtins/echo/echo.c`).
|
- Keep file names lowercase with underscores (e.g., `src/builtins/echo/echo.c`).
|
||||||
- Keep headers in `include/` and expose only what modules need.
|
- Keep headers in `include/` and expose only what modules need.
|
||||||
|
- Before adding or changing code, check `allowed.txt` to know which functions are permitted.
|
||||||
|
- Any function not listed in `allowed.txt` is not allowed in this project.
|
||||||
|
|
||||||
## Testing Guidelines
|
## Testing Guidelines
|
||||||
- There is no automated test runner. Use manual checks in `docs/tests.md` and basic shell behavior checks (pipes, redirects, builtins).
|
- There is no automated test runner. Use manual checks in `docs/tests.md` and basic shell behavior checks (pipes, redirects, builtins).
|
||||||
|
- A local builtin edge-case script exists at `tests/builtins_edge_cases.sh` (expects a compiled `./minishell`).
|
||||||
- When debugging memory issues, run under valgrind and use the suppression file in `valgrind/readline.supp`.
|
- When debugging memory issues, run under valgrind and use the suppression file in `valgrind/readline.supp`.
|
||||||
|
|
||||||
|
## Builtins Status
|
||||||
|
- `cd`: handles `HOME` fallback, `cd -` via `OLDPWD`, updates `PWD`/`OLDPWD`, and returns failure on invalid usage (`too many arguments`, missing `HOME`/`OLDPWD`).
|
||||||
|
- `echo`: supports repeated `-n` flags (`-n`, `-nnn`) and prints remaining args preserving spaces between tokens.
|
||||||
|
- `env`: prints current environment as `KEY=VALUE`; returns failure when called with extra arguments.
|
||||||
|
- `exit`: validates numeric argument (with overflow checks), returns `1` on `too many arguments` without exiting, and exits with `2` on non-numeric argument.
|
||||||
|
- `export`: supports `NAME=VALUE` and `NAME` (stored as empty value), validates identifiers, and returns failure when any identifier is invalid.
|
||||||
|
- `pwd`: prints working directory using dynamic `getcwd` and returns failure if `getcwd` fails.
|
||||||
|
- `unset`: validates identifiers and removes matching variables from the environment map.
|
||||||
|
|
||||||
## Commit & Pull Request Guidelines
|
## Commit & Pull Request Guidelines
|
||||||
- Commit messages in this repo use a simple `type: summary` format (examples: `update: ...`, `fix: ...`). Keep summaries short and specific.
|
- Commit messages in this repo use a simple `type: summary` format (examples: `update: ...`, `fix: ...`). Keep summaries short and specific.
|
||||||
- For PRs, include:
|
- For PRs, include:
|
||||||
|
|||||||
177
allowed.txt
Normal file
177
allowed.txt
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
[minishell_allowed]
|
||||||
|
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]
|
||||||
|
ft_atoi
|
||||||
|
ft_atoi_base
|
||||||
|
ft_atol
|
||||||
|
ft_bzero
|
||||||
|
ft_calloc
|
||||||
|
ft_cdlstadd_back
|
||||||
|
ft_cdlstadd_front
|
||||||
|
ft_cdlstclear
|
||||||
|
ft_cdlstdelone
|
||||||
|
ft_cdlstiter
|
||||||
|
ft_cdlstlast
|
||||||
|
ft_cdlstmap
|
||||||
|
ft_cdlstnew
|
||||||
|
ft_cdlstsize
|
||||||
|
ft_clstadd_back
|
||||||
|
ft_clstadd_front
|
||||||
|
ft_clstclear
|
||||||
|
ft_clstdelone
|
||||||
|
ft_clstiter
|
||||||
|
ft_clstlast
|
||||||
|
ft_clstmap
|
||||||
|
ft_clstnew
|
||||||
|
ft_clstsize
|
||||||
|
ft_dlstadd_back
|
||||||
|
ft_dlstadd_front
|
||||||
|
ft_dlstclear
|
||||||
|
ft_dlstdelone
|
||||||
|
ft_dlstiter
|
||||||
|
ft_dlstlast
|
||||||
|
ft_dlstmap
|
||||||
|
ft_dlstnew
|
||||||
|
ft_dlstsize
|
||||||
|
ft_eputchar
|
||||||
|
ft_eputendl
|
||||||
|
ft_eputnbr
|
||||||
|
ft_eputstr
|
||||||
|
ft_free
|
||||||
|
ft_free_split
|
||||||
|
ft_hashmap_clear
|
||||||
|
ft_hashmap_clear_keys
|
||||||
|
ft_hashmap_contains_key
|
||||||
|
ft_hashmap_entries
|
||||||
|
ft_hashmap_get
|
||||||
|
ft_hashmap_hashstr
|
||||||
|
ft_hashmap_new
|
||||||
|
ft_hashmap_put
|
||||||
|
ft_hashmap_remove
|
||||||
|
ft_hashmap_strcmp
|
||||||
|
ft_hashstr
|
||||||
|
ft_iabs
|
||||||
|
ft_imin
|
||||||
|
ft_isalnum
|
||||||
|
ft_isalpha
|
||||||
|
ft_isascii
|
||||||
|
ft_iscntrl
|
||||||
|
ft_isdigit
|
||||||
|
ft_islower
|
||||||
|
ft_isprint
|
||||||
|
ft_isspace
|
||||||
|
ft_isupper
|
||||||
|
ft_itoa
|
||||||
|
ft_itoa_base
|
||||||
|
ft_lstadd_back
|
||||||
|
ft_lstadd_front
|
||||||
|
ft_lstclear
|
||||||
|
ft_lstclear_nodes
|
||||||
|
ft_lstdelone
|
||||||
|
ft_lstiter
|
||||||
|
ft_lstlast
|
||||||
|
ft_lstmap
|
||||||
|
ft_lstnew
|
||||||
|
ft_lstsize
|
||||||
|
ft_ltoa
|
||||||
|
ft_memchr
|
||||||
|
ft_memcmp
|
||||||
|
ft_memcpy
|
||||||
|
ft_memmove
|
||||||
|
ft_memset
|
||||||
|
ft_nsplit
|
||||||
|
ft_pow
|
||||||
|
ft_putchar
|
||||||
|
ft_putchar_fd
|
||||||
|
ft_putendl
|
||||||
|
ft_putendl_fd
|
||||||
|
ft_putnbr
|
||||||
|
ft_putnbr_fd
|
||||||
|
ft_putstr
|
||||||
|
ft_putstr_fd
|
||||||
|
ft_realloc
|
||||||
|
ft_split
|
||||||
|
ft_strchr
|
||||||
|
ft_strcmp
|
||||||
|
ft_strdup
|
||||||
|
ft_strisnum
|
||||||
|
ft_striteri
|
||||||
|
ft_strjoin
|
||||||
|
ft_strlcat
|
||||||
|
ft_strlcpy
|
||||||
|
ft_strlen
|
||||||
|
ft_strmapi
|
||||||
|
ft_strncmp
|
||||||
|
ft_strncpy
|
||||||
|
ft_strnjoin
|
||||||
|
ft_strnstr
|
||||||
|
ft_strrchr
|
||||||
|
ft_strtrim
|
||||||
|
ft_substr
|
||||||
|
ft_swap
|
||||||
|
ft_tolower
|
||||||
|
ft_toupper
|
||||||
|
ft_uitoa
|
||||||
|
ft_uitoa_base
|
||||||
|
ft_ultoa_base
|
||||||
|
|
||||||
|
[get_next_line]
|
||||||
|
get_next_line
|
||||||
|
|
||||||
|
[ft_printf]
|
||||||
|
ft_eprintf
|
||||||
|
ft_fprintf
|
||||||
|
ft_printf
|
||||||
Reference in New Issue
Block a user