42sh Documentation
A POSIX-compliant shell built at 42.
Core
- 42sh — Shell State
- AST — Abstract Syntax Tree
- Builtins
- Executor
MAX_PIPELINEMAX_SAVED_FDSexecutor_execute()execute_simple_command()execute_pipeline()execute_and()execute_or()execute_sequence()execute_subshell()execute_block()execute_background()setup_redirections()restore_redirections()setup_heredoc()find_command()exec_pipeline_external()get_exit_status()split_assignment()- executor.c — Dispatch
- exec_command.c — Simple Commands
- exec_logical.c — &&, ||, ;
- exec_pipeline.c — Pipes
- exec_subshell.c — Subshell, Block, Background
- redirections.c — I/O Redirections
- heredoc.c — Here-documents
- command_search.c — PATH Lookup
- exec_utils.c — Utilities
- Expander
- History
- Job Control
- Lexer
TOKt_token_typelexer_tokenize()lexer_check_quotes()lexer_free_tokens()token_new()token_free()is_operator()is_operator_start()read_operator()read_word()t_operatort_token- lexer.c — Main Entry Point
- lexer_words.c — Word Tokens
- lexer_operator.c — Operator Tokens
- token.c — Token Helpers
- lexer_display.c — Debug Display
- Parser
parser_parse()parser_collect_heredocs()heredoc_expand_config()parser_accept()is_redir()parser_peek()parser_next()parse_subshell()parse_block()parse_command()parse_simple_command()parse_pipeline()parse_and_or()parse_list()t_parser- parser.c — Main Entry Point
- parser_command.c — Simple Commands
- parser_pipeline.c — Pipes
- parser_and_or.c — Logical Operators
- parser_list.c — Sequences and Background
- parser_group.c — Subshells and Blocks
- parser_heredoc.c — Here-documents
- parser_utils.c — Utilities
- memory.c — AST Memory Management
- ast_display.c — Debug Display
- Signals
- Variables
Tests
- minunit.h — Test Framework
- test_runner.c
- test_btree.c
- test_dlist.c
- test_history.c
- test_lexer.c
nth_token()assert_token_type()test_token_new_basic()test_token_new_io_number()test_is_operator_true()test_is_operator_false()test_is_operator_start_simple()test_is_operator_start_io_number()test_is_operator_start_digit_not_redir()test_is_operator_start_word()test_read_word_simple()test_read_word_single_quote()test_read_word_double_quote()test_read_word_backslash_escape()test_read_word_stops_at_operator()test_read_word_pipe_in_single_quote()operator_type()read_operator_crashes()test_read_operator_single_char()test_read_operator_double_char()test_read_operator_io_number()test_read_operator_malformed_no_crash()test_tokenize_simple_command()test_tokenize_pipe()test_tokenize_redirect_out()test_tokenize_heredoc()test_tokenize_heredoc_strip()test_tokenize_empty()test_tokenize_whitespace_trimmed()test_tokenize_and_or()test_tokenize_quoted_operators()test_tokenize_io_number()test_tokenize_subshell()test_tokenize_newline_separator()test_lexer_suite()
- test_list.c
- test_parser.c
test_simple_command()test_command_args()test_pipe()test_and()test_or()test_sequence()test_subshell_pipe()test_subshell_redir()test_redirection()test_complex_redir()test_multiple_redirs()test_background_separator()test_multiple_background_chain()test_trailing_background()test_pipe_newline()test_and_newline()test_only_pipe()test_only_and()test_only_or_and()test_unclose_parenthesis()test_unopen_parenthesis()test_redirs_in_a_row()test_heredoc_basic()test_heredoc_stripped_basic()test_heredoc_multiline()test_heredoc_stripped_multiline()test_heredoc_quoted_no_expand()test_heredoc_stripped_quoted_no_expand()test_heredoc_pipe()test_heredoc_stripped_pipe()test_heredoc_with_redir()test_heredoc_stripped_with_redir()test_heredoc_unterminated()test_heredoc_stripped_unterminated()test_heredoc_group()test_heredoc_stripped_group()test_assignment()test_multiple_assignments()test_assignment_only()test_assignment_after_command()test_assignment_and_args()test_assignment_with_redir()test_assignment_in_pipeline()test_invalid_assignment_digit()test_empty_value_assignment()test_plus_equals_not_assignment()test_assignment_before_subshell()test_parser_suite()
- test_executor.c
stub_shell_init()stub_shell_cleanup()fork_exit_and_get()fork_signal_and_get()test_get_exit_status()test_split_assignment()test_heredoc()test_redirections_output()test_redirections_append()test_redirections_input()test_redirections_heredoc_in_list()test_redirections_bad_file()test_redirections_save_restore()make_true_cmd()make_false_cmd()free_cmd_ast()make_echo_to_file()free_echo_ast()test_execute_and()test_execute_or()test_execute_sequence()test_execute_external_command()test_execute_builtin_command()test_execute_pipeline()test_execute_pipeline_three()test_pipeline_exit_status()test_execute_subshell()test_execute_subshell_isolation()test_execute_block()test_execute_background()test_executor_dispatch()test_complex_logical_chains()test_pipeline_with_heredoc()test_sequence_mixed()test_executor_suite()
- test_stubs.c