Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
194 commits
Select commit Hold shift + click to select a range
9027235
add libft
Sep 29, 2025
21cf1c0
add pull_request_template.md
Sep 29, 2025
52ca353
delete comment_outted test_code
Sep 29, 2025
fe95557
delete .vscode/settings.json
Sep 29, 2025
ce5d179
revise Makefile and header file
Sep 29, 2025
a37dd34
add Makefile template
Sep 29, 2025
68c5cc4
add src directory template
Sep 29, 2025
fb7a050
add includes template
Sep 29, 2025
7a13579
revise some
Sep 29, 2025
1967447
Merge pull request #2 from Jikuhara/jiku/add_PRcomment_template
jiku0730 Sep 29, 2025
949f8bb
Merge pull request #1 from Jikuhara/jiku/add_libft
urassh Sep 29, 2025
d10768f
Merge pull request #3 from Jikuhara/jiku/create_directory_template
jiku0730 Sep 29, 2025
88b065c
minishellディレクトリから平坦化
urassh Oct 1, 2025
8251be5
fix: minishell.hのnorminette修正
urassh Oct 1, 2025
e4116a0
Merge pull request #7 from jiku0730/urassh/fatting-directory
jiku0730 Oct 1, 2025
c1c3bcc
feat: プロンプト機能の実装
urassh Oct 1, 2025
cfebedc
revise prompt
Oct 1, 2025
1fee2dc
fix: readline関数を使うように
urassh Oct 1, 2025
c434689
add: 動作確認の項目を追加した
urassh Oct 1, 2025
8d521b6
Merge pull request #11 from jiku0730/urassh/add-template
jiku0730 Oct 1, 2025
bb4aad9
GitHub Actions による Norminette 自動チェック機能の追加 (#9)
urassh Oct 1, 2025
2512f81
GitHubActionsでビルドのテストも追加 (#10)
urassh Oct 1, 2025
0d1b498
fix: 改行するように
urassh Oct 2, 2025
6d02605
voidにした
urassh Oct 2, 2025
f29258e
fix: Makefile
urassh Oct 2, 2025
d33c71b
Merge branch 'develop' into urassh/prompt
urassh Oct 2, 2025
6b418eb
add: readline関数を使うためのlibreadline-devライブラリを追加
urassh Oct 2, 2025
b7fbac8
fix: norminette
urassh Oct 2, 2025
4532c12
libftの相対パス指定を修正
urassh Oct 2, 2025
8cde1cd
delete: stdioは不要なので削除
urassh Oct 2, 2025
7eadf79
on_inputを修正
urassh Oct 2, 2025
6e03500
Merge pull request #8 from jiku0730/urassh/prompt
jiku0730 Oct 4, 2025
c9f3748
feat: on_inputをcallbackディレクトリに追加
urassh Oct 10, 2025
84ce2f6
faet: tokenize
urassh Oct 12, 2025
9d706de
fix: operatorの修正
urassh Oct 12, 2025
be8d791
add: ()の定義を追加
urassh Oct 12, 2025
1c3576a
fix: on_exitのシグネチャ被りのビルドエラーを修正
urassh Oct 13, 2025
13f922e
fix: quotoの修正
urassh Oct 13, 2025
abbaab2
add: ft_isspace_str
urassh Oct 13, 2025
a908253
rename: is_blank_line
urassh Oct 14, 2025
f596ce7
fix: promptで空行検知
urassh Oct 14, 2025
fdf4d6f
rename: file
urassh Oct 14, 2025
c7dd626
fix: unsigned char
urassh Oct 14, 2025
b3e55b9
fix: is_operatorのシグネチャにconstを含めるように
urassh Oct 14, 2025
01e9286
feat: tokenize_checkerを導入した
urassh Oct 14, 2025
cd0c604
fix: substr失敗時の処理
urassh Oct 16, 2025
197a36e
fix: push_tokenがエラー時にstateをon_errorにするように
urassh Oct 16, 2025
ffffb68
add: init_store, free_store
urassh Oct 16, 2025
4338123
feat: add_buffer, push_token
urassh Oct 16, 2025
5ce6a22
fix: シグネチャをシンプルにした
urassh Oct 16, 2025
57b040a
fix: 大まかな修正は完了
urassh Oct 16, 2025
38016b7
fix: in_normal
urassh Oct 16, 2025
3bc8dd1
fix: 空の時はpushしないように
urassh Oct 16, 2025
dd95283
fix: norminette
urassh Oct 16, 2025
5f7d636
minishell.hのマクロ宣言を削除
urassh Oct 16, 2025
6c572d8
in_operatorのpush_token失敗時の処理
urassh Oct 16, 2025
4db02f2
fix: const化
urassh Oct 16, 2025
d9de4a0
fix: add_bufferの処理を修正
urassh Oct 17, 2025
0498337
これでリーク治ると思うんだよねぇ
urassh Oct 17, 2025
a0e4537
fix: error
urassh Oct 18, 2025
a866f89
add: const
urassh Oct 22, 2025
8509ab5
fix: rtv_tokens
urassh Oct 22, 2025
6da947c
Merge pull request #15 from jiku0730/urassh/tokenize
jiku0730 Oct 22, 2025
6d62184
refactor
urassh Oct 22, 2025
655db4d
fix: sigle quoteのadd_buffer失敗時でも対応できるように
urassh Oct 22, 2025
3a275bd
in_operatorをもうちょいわかりやすく
urassh Oct 22, 2025
471fb7f
fix: norminette
urassh Oct 22, 2025
f75e76b
fix: in_operatorモードでも終わりが完了できるように
urassh Oct 22, 2025
77530c2
add: 検知しないリークを定義
urassh Oct 23, 2025
5a7bd92
add: rl_clear_history
urassh Oct 23, 2025
24c7d47
Merge pull request #16 from jiku0730/urassh/refactor-tokenize
jiku0730 Nov 3, 2025
720bf10
Merge pull request #17 from jiku0730/urassh/leak-ignore
jiku0730 Nov 3, 2025
2581a15
② メモリリークのCIを作成, Dockerの追加 (#18)
urassh Nov 3, 2025
b475af5
feature: add test command to Makefile (#19) (#20)
jiku0730 Nov 5, 2025
a8e483c
HashTableを定義
urassh Nov 5, 2025
3ad6237
finish: make parser
Nov 20, 2025
4c0fcf8
revise: norminette
Nov 20, 2025
3ea13fc
revise: norminette
Nov 20, 2025
c26a18a
tokenize時にクォートを消さないように (#25)
urassh Nov 20, 2025
c385680
change: parser's prototype declearation
Nov 20, 2025
88690be
heredocの実装 (#30)
urassh Nov 21, 2025
2e38515
NorminetteCIのトリガーを修正 (#28)
urassh Nov 21, 2025
1e2bc36
refactor: ht_hash
urassh Nov 23, 2025
0b7f481
refactor: create_nodeでcallocを使うように
urassh Nov 23, 2025
b6e9fec
fix: ht_createでcallocを使うように
urassh Nov 23, 2025
45e3b26
Merge pull request #26 from jiku0730/urassh/hash-table
jiku0730 Nov 24, 2025
d056143
feat: env_tableを使うように
urassh Nov 26, 2025
38c5367
feat: build_env_table
urassh Nov 26, 2025
684d27f
feat: export_envp.c
urassh Nov 26, 2025
ab62ef2
faet: build_env_tableをminishellに統合した
urassh Nov 26, 2025
a03319d
add: Makefileにenv_tableに関する定義を追加
urassh Nov 26, 2025
841a931
add: env_table_checker.c
urassh Nov 26, 2025
5c6d30f
fix: insert_env_entriesの戻り型を修正
urassh Nov 26, 2025
279c8d8
fix: export_envpのタイポ修正
urassh Nov 26, 2025
ac2952b
mainを本番で分割
urassh Nov 26, 2025
7ab1128
add: test_execve_with_envpも追加
urassh Nov 26, 2025
829244e
fix: free_envp_arrayでのNULL埋め
urassh Nov 26, 2025
d1c6ad2
fix: char *const envp[]
urassh Nov 26, 2025
f7fa7d5
Merge pull request #31 from jiku0730/urassh/env_table
jiku0730 Nov 26, 2025
94a0f93
Merge branch 'develop' into jiku/feature/parser
Nov 26, 2025
f1df0c2
add: parser_checker.c
Nov 26, 2025
e4cda5a
add: parser_checker.c
Nov 26, 2025
aabbb50
delete: get_content ,and change:cursor->current ,and refactor: parser…
Nov 26, 2025
f052401
revise: parser_redir's return value from bool to int(use macro ERROR …
Nov 27, 2025
9a0ed22
delete: HEREDOC macro
Nov 27, 2025
0fe3e76
delete: is_EOF function
Nov 27, 2025
99aaff6
delete: don't use is_EOF
Nov 27, 2025
d9f3434
Merge pull request #27 from jiku0730/jiku/feature/parser
jiku0730 Nov 27, 2025
5536684
パターンマッチの基本実装 (#32)
urassh Nov 27, 2025
fefeb16
シェルテーブルを定義した (#33)
urassh Nov 27, 2025
b3b2807
feat: get_directory_entries
urassh Nov 27, 2025
3b6cf4f
feaet: get_directory_entriesを再帰で読み取るように
urassh Nov 27, 2025
e36c8cb
feat: get_directory_all_entries
urassh Nov 27, 2025
1c45cdb
とりまcheckerはできた
urassh Nov 27, 2025
d96bb39
fix: 再帰関数が間違っていたのでその修正/full_pathでエントリに追加されるように
urassh Nov 27, 2025
0a85841
fix: join_pathのjoin後のリークチェックを追加
urassh Nov 27, 2025
2418de6
fix: directory_checkerでexitで抜けられるように
urassh Nov 27, 2025
add0fac
fix: norminette
urassh Nov 27, 2025
043414d
fix: directory_checker leaks
urassh Nov 27, 2025
cccd663
directory_checkerでexitする時にinputもfreeするように
urassh Nov 27, 2025
5ecbe24
これでどうだ!!!
urassh Nov 27, 2025
98a00d4
fix: get_directory_entriesのNULLガードを追加
urassh Nov 29, 2025
d2136ad
Merge pull request #34 from jiku0730/urassh/directories
jiku0730 Nov 30, 2025
7322b99
① echoコマンドを実装した (#36)
urassh Nov 30, 2025
3909a42
promptをjikusshに変更しました。 (#40)
jiku0730 Nov 30, 2025
ffa80d5
ヘッダーファイルの両端を<> からdouble_qoutationに変更しました。 (#42)
jiku0730 Dec 1, 2025
d587c66
相対パスを絶対パスに変換するコンポーネントの実装 (#43)
urassh Dec 1, 2025
cbef1a2
② pwdコマンドを実装した (#37)
urassh Dec 1, 2025
ce624d1
③ exportコマンドを実装した (#38)
urassh Jan 7, 2026
92e3b1b
④ unsetコマンドを実装した (#39)
urassh Jan 7, 2026
757b1fe
fix: tokenizeでダブルとシングルのクォートの区別が必要なことに気がついたのでその修正 (#44)
urassh Jan 8, 2026
70c1a8a
fix: 42header about urassh->surayama (#46)
jiku0730 Jan 16, 2026
232b6e3
refactor: tokenize (#47)
jiku0730 Jan 16, 2026
da6d579
Refactor: checker 部分で多くの出力部分をPrintfでまとめました。 (#45)
jiku0730 Jan 16, 2026
e0fc665
feat: make docs directory (#48)
jiku0730 Jan 16, 2026
2c201b1
⑤ cd コマンドを実装した (#41)
urassh Jan 22, 2026
f7a4651
リストの要素を新リストでスワップできるように (#50)
urassh Feb 1, 2026
e50e3ef
tokenizeを全ての演算子単位で分割するように (#49)
urassh Feb 5, 2026
1fd9fd7
クォートを削除するコンポーネントの実装 (#54)
urassh Feb 13, 2026
11a1b2d
expandの実装 (#53)
urassh Feb 13, 2026
acb5be1
expandの実装 (#53)
urassh Feb 13, 2026
c51a43f
Claude Code のセットアップ (#58)
urassh Mar 3, 2026
fd419ec
add: join_path.cをsrc/components/pathに追加しました。 (#59)
jiku0730 Mar 3, 2026
aa8d230
パス解決コンポーネントの実装 (#56)
urassh Mar 3, 2026
5d209ad
fix: export の返り値を終了ステータス (0/1) に修正 (#62)
urassh Mar 3, 2026
cfa843b
parser → parse にリネーム(他パイプライン関数と命名統一) (#63)
urassh Mar 3, 2026
c087ef1
expand レイヤーの統合と命名規約の統一 (#61)
urassh Mar 3, 2026
197e302
全チェッカーを CLI フラグで起動可能にする (#65)
urassh Apr 5, 2026
b8a24c9
C言語のルールを追加 (#66)
urassh Apr 5, 2026
acb5696
cd に CDPATH 対応を追加 + builtin ディレクトリ整理 (#64)
urassh Apr 11, 2026
0fae5c6
シグナルハンドリングの実装(sigint) (#67)
urassh Apr 11, 2026
286620a
execute部分を作成しました。 (#35)
jiku0730 Apr 11, 2026
af5d691
README.md を追加 (#68)
urassh Apr 11, 2026
78f65c5
提出用にテスト・デバッグコードを削除
urassh Apr 16, 2026
83391bc
add: on_inputを本番用に組み替え
urassh Apr 16, 2026
d91bab9
delete: docs削除/executorのヘッダ追加
urassh Apr 16, 2026
3243355
fix: 外部コマンド実行時に fork して親プロセスが終了しないように修正
urassh Apr 16, 2026
93ad269
refactor: exec_cmd.c に外部コマンド実行を統合し重複 join_path を削除
urassh Apr 16, 2026
d6cd77e
fix: 存在しないコマンドが入力された時の挙動を修正
urassh Apr 16, 2026
9782b29
fix: パスなしワイルドカードがフルパスで展開される問題を修正
urassh Apr 16, 2026
c2aee2b
fix: クォート境界でトークンが分割される問題を修正
urassh Apr 16, 2026
83105bf
feat: コマンド実行中のシグナルハンドリングを実装
urassh Apr 16, 2026
f3bd145
feat: && / || 論理演算子のパーサ・実行サポートを追加
urassh Apr 16, 2026
5796375
wip: exec_ast の戻り値を $? として shell_table に保存
urassh Apr 16, 2026
d190945
refactor: expand を executor に移動し、コマンド単位で展開する
urassh Apr 16, 2026
3022d43
feat: サブシェル (cmd1 && cmd2) | cmd3 のパーサ・実行サポート
urassh Apr 16, 2026
20f70ce
fix: クォート境界でトークンが分割される問題を修正
urassh Apr 16, 2026
aedc1ad
fix: クォート削除でクォートの開閉状態を追跡するよう修正
urassh Apr 16, 2026
9871904
feat: 閉じられていないクォートのエラーメッセージを追加
urassh Apr 16, 2026
c1066fa
fix: heredoc 入力中の Ctrl+C でプロンプトに戻るよう修正
urassh Apr 16, 2026
0a1555f
fix: リダイレクトが親プロセスの fd を壊す問題を修正
urassh Apr 16, 2026
3919151
Merge branch 'prod' into feature/signal-exec
urassh Apr 16, 2026
7a2cc02
Merge branch 'prod' into feature/logical-operators
urassh Apr 16, 2026
ccc444d
⓪ fix: on_input にパイプライン実装と $? 展開対応 (#75)
jiku0730 Apr 17, 2026
ede8631
chore: expand層とHeaderの関数の順番を合わせた。
jiku0730 Apr 17, 2026
873cf35
fix: includes/prompt.hのNormを修正。
jiku0730 Apr 17, 2026
51b5d51
feat: export コマンドを bash 互換に改善
urassh Apr 17, 2026
8bf1ed2
fix: リダイレクトが親プロセスの fd を壊す問題を修正
urassh Apr 16, 2026
b50445f
fix: ビルトイン判定を実行前に行い二重実行を防止
urassh Apr 17, 2026
73b1821
fix: リダイレクトのパース判定とprintf バッファフラッシュを修正
urassh Apr 17, 2026
f05fed2
Merge branch 'prod' into feature/logical-operators
urassh Apr 17, 2026
dbbac71
refactor: exec_cmd から expand 呼び出しを削除
urassh Apr 17, 2026
35540c4
Merge branch 'fix/redirect' into prod-urassh
urassh Apr 18, 2026
e5f9cc3
Merge branch 'feature/signal-exec' into prod-urassh
urassh Apr 18, 2026
b4d4f3d
Merge branch 'feature/subshell' into prod-urassh
urassh Apr 18, 2026
2738a92
fix: ビルトイン出力をwriteに変更しサブシェルのシグナル制御を追加
urassh Apr 18, 2026
7392b7f
fix: parse_cmdのnorminette違反を修正
urassh Apr 18, 2026
b0bd7f9
fix: ディレクトリ実行時のエラー処理とexpandのコマンド単位実行への移行
urassh Apr 18, 2026
ac492e8
fix: expand_cmd失敗時のreturnを-1に変更
urassh Apr 18, 2026
63c463d
fix: SIGQUIT時にQuit: 3を表示するように修正
urassh Apr 18, 2026
5748aa0
fix: Word意外をparseエラーが出るように修正。
jiku0730 Apr 18, 2026
9a1bb41
fix
urassh Apr 18, 2026
1ef65c5
最終調整
urassh Apr 18, 2026
51e6784
delete claude, github
urassh Apr 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 199 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: kjikuhar <kjikuhar@student.42tokyo.jp> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/05/18 21:11:39 by kjikuhar #+# #+# #
# Updated: 2026/04/17 21:12:31 by kjikuhar ### ########.fr #
# #
# **************************************************************************** #


#-----------------------------------------------------------------------------
#> options
#-----------------------------------------------------------------------------
BLACK := \033[30m
RED := \033[31m
GREEN := \033[32m
YELLOW := \033[33m
BLUE := \033[96m
MAGENTA := \033[38;5;206m
CYAN := \033[36m
WHITE := \033[37m
RESET := \033[0m
BOLD := \033[1m
DIM := \033[2m
ITALIC := \033[3m
UNDER := \033[4m
BLINK := \033[5m
REVERSE := \033[7m
HIDDEN := \033[8m
PINK := \033[35m

#-----------------------------------------------------------------------------

#▸ variables

#-----------------------------------------------------------------------------

NAME := minishell

#─ compile config ────────────────────────────────────────────────────────────

CC := cc
CFLAGS := -Wall -Wextra -Werror -Iincludes -Ilibft

#─ directory name ────────────────────────────────────────────────────────────

SRCDIR := src
MAND := mandatory
OBJDIR := obj
LIBFT_DIR := libft
LIBFT_A := $(LIBFT_DIR)/libft.a

#─ sources & objects ─────────────────────────────────────────────────────────

#mandatory sources
SRCS_MAND := src/main.c \
src/builtin/echo/echo.c \
src/builtin/export/export.c \
src/builtin/export/export_errors.c \
src/builtin/pwd/pwd.c \
src/builtin/unset/unset.c \
src/builtin/cd/cd.c \
src/builtin/cd/search_cdpath.c \
src/builtin/exit/exit.c \
src/prompt/prompt.c \
src/callback/on_input.c \
src/tokenize/tokenize.c \
src/tokenize/is_specific.c \
src/tokenize/state/in_normal.c \
src/tokenize/state/in_normal/by_last.c \
src/tokenize/state/in_normal/by_space.c \
src/tokenize/state/in_normal/by_operator.c \
src/tokenize/state/in_normal/by_quote.c \
src/tokenize/state/in_normal/by_parenthesis.c \
src/tokenize/state/in_double_quote.c \
src/tokenize/state/in_single_quote.c \
src/tokenize/state/in_operator.c \
src/tokenize/state/on_success.c \
src/tokenize/state/on_error.c \
src/tokenize/store/free_store.c \
src/tokenize/store/push_token.c \
src/tokenize/store/add_buffer.c \
src/parse/parse.c \
src/parse/parse_list.c \
src/parse/parse_pipeline.c \
src/parse/utils/add_to_cmd.c \
src/parse/utils/new_ast_node.c \
src/parse/utils/new_cmd.c \
src/parse/utils/new_redir.c \
src/parse/utils/token_check.c \
src/parse/utils/free_ast.c \
src/component/heredoc/heredoc.c \
src/component/heredoc/heredoc_prompt.c \
src/component/heredoc/heredoc_expand.c \
src/component/heredoc/tmpfile.c \
src/component/shell_table/shell_hash.c \
src/component/shell_table/shell_insert.c \
src/component/shell_table/shell_search.c \
src/component/shell_table/shell_delete.c \
src/component/shell_table/shell_destroy.c \
src/component/shell_table/shell_print.c \
src/component/shell_table/build_shell_table.c \
src/component/shell_table/export_envp.c \
src/execute/exec_ast.c \
src/execute/exec_cmd.c \
src/execute/exec_pipe.c \
src/execute/utils/ft_wexitstatus.c \
src/execute/utils/ft_wifexited.c \
src/execute/command/find_exec_path.c \
src/execute/command/exec_external_cmd.c \
src/execute/command/exec_builtin_cmd.c \
src/execute/command/list_to_argv.c \
src/execute/pipe/exec_pipe_child.c \
src/execute/redirects/exec_redirs.c \
src/component/directory/list_directory.c \
src/component/directory/list_directory_recursive.c \
src/component/path/to_absolute_path.c \
src/component/path/join_path.c \
src/component/path/append_path.c \
src/component/path/resolve_relative_path.c \
src/expand/expand.c \
src/expand/expand_cmd.c \
src/expand/expand_parameter/expand_parameter.c \
src/expand/expand_parameter/state/in_normal_expand.c \
src/expand/expand_parameter/state/in_double_quote_expand.c \
src/expand/expand_parameter/state/in_single_quote_expand.c \
src/expand/expand_parameter/state/on_success_expand.c \
src/expand/expand_parameter/state/on_error_expand.c \
src/expand/expand_parameter/store/push_token_expand.c \
src/expand/expand_parameter/store/add_buffer_expand.c \
src/expand/expand_parameter/store/get_key_length_expand.c \
src/expand/expand_parameter/store/free_store_expand.c \
src/expand/expand_tilde/expand_tilde.c \
src/expand/expand_wildcard/resolve_wildcard.c \
src/expand/expand_wildcard/match_wildcard.c \
src/expand/expand_wildcard/expand_wildcard.c \
src/expand/expand_remove_quotes/expand_remove_quotes.c \
src/expand/expand_question/expand_question.c \
src/signal/setup_signal_handlers.c \
src/signal/set_signals.c \

SRCS_BONUS :=

#object files

OBJS_MAND := $(SRCS_MAND:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
OBJS_BONUS := $(SRCS_BONUS:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
# OBJS := $(OBJS_MAND) $(OBJS_BONUS)

#-----------------------------------------------------------------------------

#▸ rules

#-----------------------------------------------------------------------------

all: $(NAME)

$(NAME): $(LIBFT_A) $(OBJS_MAND)
@echo "Compiled with $(GREEN)$(BOLD)$(CFLAGS)$(RESET)"
@$(CC) $(CFLAGS) $(OBJS_MAND) -o $@ $(LIBFT_A) -lreadline
@echo "$(YELLOW)$(BOLD)========================================="
@echo " You can use My $(NAME)!!"
@echo "=========================================$(RESET)"

# compile object files

$(OBJDIR)/%.o: $(SRCDIR)/%.c
@mkdir -p $(dir $@)
@echo "Compiled ✅ $(WHITE) $(BOLD) $^ $(RESET)"
@$(CC) $(CFLAGS) -c -o $@ $^

# libft
$(LIBFT_A):
@$(MAKE) -C $(LIBFT_DIR)

# clean targets
clean:
@$(MAKE) -C $(LIBFT_DIR) clean
@rm -rf $(OBJDIR)

fclean: clean
@$(MAKE) -C $(LIBFT_DIR) fclean
@rm -f $(NAME)

re: fclean all

# bonus: $(LIBFT_A) $(OBJS_BONUS)
# @cp $(LIBFT_A) $(NAME)
# @echo "Compiled with $(GREEN)$(BOLD)$(CFLAGS)$(RESET)"
# @ar rcs $(NAME) $(OBJS_BONUS)
# @echo "$(YELLOW)$(BOLD)========================================="
# @echo " You can use My Bonus_$(NAME)!!"
# @echo "=========================================$(RESET)"

.PHONY: all clean fclean re bonus

101 changes: 100 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,100 @@
test
*This project has been created as part of the 42 curriculum by surayama, kjikuhar.*

# minishell

## Description

Minishell is a simplified shell implementation written in C, inspired by bash. The goal of this project is to understand how a real shell works by building one from scratch: parsing user input, managing environment variables, handling redirections and pipes, and executing commands.

Key features include:

- Interactive prompt with command history (GNU readline)
- Tokenization and parsing of shell commands into an AST (Abstract Syntax Tree)
- Pipes (`|`) and redirections (`<`, `>`, `>>`, `<<`)
- Environment variable expansion (`$VAR`, `$?`)
- Quote handling (single and double quotes)
- Here-documents (`<<`)
- Built-in commands: `echo`, `cd`, `pwd`, `export`, `unset`, `env`, `exit`
- Signal handling (`Ctrl+C`, `Ctrl+D`, `Ctrl+\`)

## Instructions

### Prerequisites

- Docker (recommended for building and running)
- Or: GCC, Make, GNU readline library

### Build and Run

The recommended way to build and run is inside the Docker environment:

```bash
# Enter the Docker container
make docker

# Build inside the container
make

# Run the shell
./minishell
```

### Other Make Targets

| Command | Description |
|-----------------|--------------------------------------------------|
| `make` | Build the project |
| `make re` | Clean rebuild |
| `make clean` | Remove object files |
| `make fclean` | Remove object files and binary |
| `make norm` | Run norminette style checker |
| `make valgrind` | Rebuild and run with valgrind for leak detection |
| `make test` | Run norminette + valgrind |

### Usage Examples

```
$ ./minishell
minishell$ echo hello world
hello world
minishell$ ls -la | grep Makefile
-rw-r--r-- 1 user staff 2048 Apr 10 12:00 Makefile
minishell$ export FOO=bar
minishell$ echo $FOO
bar
minishell$ cat << EOF
> hello
> world
> EOF
hello
world
minishell$ exit
```

## Architecture

The shell follows an interpreter pipeline:

```
Input -> tokenize() -> heredoc() -> variable_expand() -> remove_quotes() -> parse() -> AST -> execute
```

1. **Tokenizer** -- State-machine-based lexer that splits input into tokens at operator, space, and quote boundaries.
2. **Variable Expansion** -- Expands `$VAR` syntax while respecting quote context.
3. **Quote Removal** -- Strips quote characters from expanded tokens.
4. **Parser** -- Recursive descent parser that produces a binary AST with `PIPE` (internal) and `CMD` (leaf) nodes.
5. **Executor** -- Walks the AST, sets up pipes and redirections, and executes commands via `fork`/`execve`.

## Resources

- [The Open Group Base Specifications -- Shell Command Language](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html)
- [Bash Reference Manual](https://www.gnu.org/software/bash/manual/bash.html)
- [Writing Your Own Shell (42 tutorial)](https://harm-smits.github.io/42docs/projects/minishell)
- [GNU Readline Library Documentation](https://tiswww.case.edu/php/chet/readline/rltop.html)

### Use of AI

AI (Claude Code by Anthropic) was used as a development assistant for the following tasks:

- Code review and debugging assistance
- Generating boilerplate code and Makefile configurations
30 changes: 30 additions & 0 deletions includes/builtin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* builtin.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: surayama <surayama@student.42tokyo.jp> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/29 17:16:51 by surayama #+# #+# */
/* Updated: 2026/04/06 07:41:22 by surayama ### ########.fr */
/* */
/* ************************************************************************** */

#ifndef BUILTIN_H
# define BUILTIN_H

# include "path.h"
# include "shell_table.h"
# include <limits.h>
# include <stdio.h>
# include <unistd.h>

int echo(t_list *argv, t_shell_table *shell_table);
int pwd(t_list *argv, t_shell_table *shell_table);
int export(t_list *argv, t_shell_table *shell_table);
int unset(t_list *argv, t_shell_table *shell_table);
int cd(t_list *argv, t_shell_table *shell_table);
int builtin_exit(t_list *argv, t_shell_table *shell_table);
void print_export_error(const char *assignment);

#endif
25 changes: 25 additions & 0 deletions includes/constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* constants.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kjikuhar <kjikuhar@student.42tokyo.jp> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/10/16 23:14:49 by surayama #+# #+# */
/* Updated: 2026/01/16 13:59:52 by kjikuhar ### ########.fr */
/* */
/* ************************************************************************** */

#ifndef CONSTANTS_H
# define CONSTANTS_H

// macros
# define SUCCESS 0
# define ERROR -1
# define NOT_FOUND -2
# define NO_PERMISSION -3
# define NOT_A_DIRECTORY -4
# define SHELL_NAME "jikussh"
# define PROMPT "jikussh$ "

#endif
29 changes: 29 additions & 0 deletions includes/directory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* directory.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kjikuhar <kjikuhar@student.42tokyo.jp> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/27 15:25:07 by surayama #+# #+# */
/* Updated: 2025/12/01 03:28:22 by kjikuhar ### ########.fr */
/* */
/* ************************************************************************** */

#ifndef DIRECTORY_H
# define DIRECTORY_H

# include "constants.h"
# include <dirent.h>
# include <errno.h>
# include "libft.h"
# include <stdbool.h>
# include <stdlib.h>
# include <sys/stat.h>

int list_directory(const char *path, bool include_hidden,
t_list **entries);
int list_directory_recursive(const char *path, bool include_hidden,
t_list **entries);

#endif
Loading