biralavor / 42_minishell

WIP - minishell, a 42 school team project to rebuild a tiny bash, using C language. Build with @Thais-Malheiros
MIT License
1 stars 0 forks source link

adding built-ins #83

Closed biralavor closed 1 month ago

biralavor commented 1 month ago

Our subjects says:

Our shell must implement the following builtins:

- [x] echo with option -n
- [x] cd with only a relative or absolute path
- [x] pwd with no options
- [ ] export with no options
- [ ] unset with no options
- [ ] env with no options or arguments
- [ ] exit with no options
biralavor commented 1 month ago

man -k bash man bash-builtins 7

SYNOPSIS bash defines the following built-in commands:


1. :
2. .
3. [
4. alias
5. bg
6. bind
7. break
8. builtin
9. case
10. cd
11. command
12. compgen
13. complete
14. continue
15. declare
16. dirs
17. disown
18. echo
19. enable
20. eval
21. exec
22. exit
23. export
24. fc
25. fg
26. getopts
27. hash
28. help
29. history
30. if
31. jobs
32. kill
33. let
34. local
35. logout
36. popd
37. printf
38. pushd
39. pwd
40. read
41. readonly
42. return
43. set
44. shift
45. shopt
46. source
47. suspend
48. test
49. times
50. trap
51. type
52. typeset
53. ulimit
54. umask
55. unalias
56. unset
57. until
58. wait
59. while

BASH BUILTIN COMMANDS Unless otherwise noted, each builtin command documented in this section as accepting options preceded by - accepts -- to signify the end of the options. The :, true, false, and test/[ builtins do not accept options and do not treat -- specially. The exit, logout, return, break, continue, let, and shift builtins accept and process arguments beginning with - without requiring --.

Other builtins that accept arguments but are not specified as accepting options interpret arguments beginning with -- as invalid options and require -- to prevent this interpretation.

Read and execute commands from filename in the current shell environment and return the exit status of the last command executed from filename. If filename does not contain a slash, filenames in PATH are used to find the directory containing filename. The file searched for in PATH need not be executable. When bash is not in posix mode, the current directory is searched if no file is found in PATH. If the sourcepath option to the shopt builtin command is turned off, the PATH is not searched. If any arguments are supplied, they become the positional parameters when filename is executed.

Otherwise the positional parameters are unchanged. If the -T option is enabled, source inherits any trap on DEBUG; if it is not, any DEBUG trap string is saved and restored around the call to source, and source unsets the DEBUG trap while it executes. If -T is not set, and the sourced file changes the DEBUG trap, the new value is retained when source completes. The return status is the status of the last command exited within the script (0 if no commands are executed), and false if filename is not found or cannot be read.