minishell's Introduction
minishell's People
minishell's Issues
エラー出力の仕方をまとめる。
minishell: input: error string
このようなエラー出力を複数の関数で個々に処理していたので、まとめたい。
ヒアドキュメントの受け取りを子プロセスで受け取る
編集するファイル
- setdata_cmdline_redirection.c
- setdata_heredoc_cmdtype.c
- execution_start.c
- execute.h
存在しない環境変数を展開したときに空のノードが生まれてしまう
minishell$ cat $NO aaa
cat: : No such file or directory
cat: aaa: No such file or directory
コメント書く
ファイルごと、場合によっては関数ごとにコメント書く
コメントの形式は
/*
** 説明
*/
これで統一したいと思ってます
関数ごとに書くのはめんどくさそうなので基本はファイルごとで、説明が必要そうな関数、重要な関数はその上に
/*
** param (int param1)引数の説明
** param (int param2)引数の説明
** return 戻り値の説明
** 関数の説明
*/
みたいな感じで書きたいと思います
support ambiguous redirect and expand here_doc
ambiguous fileの対応と、ヒアドキュメント対応をします。
ヒアドキュメント受け取り中にCtrl + C押された時の対応
in_fdとout_fdの削除
minishell.h内のin_fdとout_fdを削除する
@ryojiroakiyama
自分の方で消しちゃって大丈夫ですか?あきやまさんのファイルの方はもう消したんでしたっけ。
exit statusをグローバル関数にする
echo aaa > > aがシンタックスエラー判定できていない
echo aaa > > a
が
echo aaa >> a
になってる。
ヒアドキュメントも。
直します。。。
変数展開時の区切り文字の判定を修正する
環境変数の終わりの判定の仕方を修正します。
bool is_delimiter(char c)
{
if (c == ' ' || c == '$' || c == '\"' || c == '\'' || c == '\0')
return (true);
else
return (false);
}
この関数をアルファベット、数字、アンバーバー以外ならtrueを返すようにすればよさそう
gif
makefileの作成
makefileを作ります。
gif
cat n<<end、cat n>>fileでシンタックスエラーが発生する。
env -i ./minishellで起動して、Ctrl+Dで終了したときにダブルフリーになる問題
env -iで実行されたときでもenvlistがNULLになってなかったのが原因ぽい
環境変数のvalueの先頭、末尾にスペースあると空のリストが生まれる問題
$ export A=" aa bb "
$ echo A
の場合
cmdlist[0]: echo
cmdlist[1]:
cmdlist[2]: aa
cmdlist[3]: bb
cmdlsit[4]:
になってる
Ctrl + Dでexitする
$単体の場合、変数展開しないようにする
$ echo $
$
bash-5.1 echo$
bash: echo$: コマンドが見つかりません
[127] bash-5.1 echo$a
bash-5.1 echo$USER
bash: echosudourio: コマンドが見つかりません
[127] bash-5.1 echo
ビルトインのexitで引数の前後のis_spaceを無視できるようにする
gif
指定されたファイルディスクリプタにリダイレクションする
コマンドが失敗した次のコマンドが実行されない問題
コマンドをtokenizeする関数でのエラー処理でstatusを見てるのでそのときstatusが0以外だった場合、前回のエラーなのか今回のエラーなのか判別ができていない。
スペースだけ入力されたときにbus errorになる
ファイルディスクリプタをリダイレクトで渡せるようにする
parser
$ echo 2>file
の場合
cmdlist: echo
iolist[1] : 2
iolist[2] : >
iolist[3] : file
にする。
c_typeにもFDか分かるようなフラグを追加する
execve実行中にCtrl+C押された時の対応
ヒアドキュメント中の対応と同じ?
環境変数の中に環境変数があった場合に展開しないようにする
実行可能ファイルが現れるまで実行ファイルを探します。
今までは、ビルトイン以外コマンドのパス検索(存在する名前なのか、ファイルなのか)に関して
PATHの頭から検索して、先に見つかったファイルを実行させていましたが、さらに実行可能ファイルかまで条件を絞ります。
変更ファイル
- wrapper3.c
- command_nonbuiltin.c
- struct.h
- Makefile
- execute.h
コマンドがビルトインでなかった時の実行ファイルの探し方を修正します。
srcs/command_notbuiltin.c/ft_stat()に検索パスを渡していますが、検索結果のパスがファイルパスなのかどうか(ディレクトリパスなのかそれ以外なのか)までの確認を取れていないので修正します。
ビルトインexitで引数なしの時メッセージ出力されない件
exitの関数でミスってたので修正します。
export、引数無しでの表示内容の変更
export VAR
export | grep VAR
VAR="(null)"
nullの表示はしないのでこれを直します。
シンタックスエラー時の終了ステータスが反映されてない問題
シンタックスエラーで終了したあと、
$ echo $?
で0が表示される。
これはお互いのコード見ないと分かんない気がするので後で話しましょう。
ls >>> a.txtがエラーにシンタックスエラーになってない問題
>>>
だけだとシンタックスエラーになってるけど
ls >>> a.txt
みたいなやつはエラー判定できてない
pwdでシンボリックリンクを辿ってしまっている
minishell$ mkdir dir
minishell$ ln -s dir link
minishell$ cd link/
minishell$ pwd
/Users/sudourio/Desktop/42tokyo/rank03/minishell/minishell_github/dir
bashだと最後のpwdがlinkになってます
ambiguous redirectを変数展開の段階で処理しないようにする
ambiguous redirectを変数展開後は放置してステータスもそのままにします。
issueを立てて、issueごとにプルリクするっていうのをやってみてます。
コンパイルエラー
未使用変数あり.
シグナルハンドラー作成
Ctrl + C 押された時の対応
Ctrl + \ 押された時の対応
ヘッダーとファイル整理
- minishell.hの型名などの整理
- コマンド実行関係のファイル名整理やnorm対応
- echoの空白出力対応
など変更します。
入力を受け付け実行する関数を作ります。
とりあえずなんかファイル作ってそこに関数作っておきます。
catバグる
$ cat outfile
の場合、
cmdlist[0] "cat"
cmdlist[1] "outfile"
cmdlist[2] ""
になってる。
原因不明。
子プロセスSEGVなどのエラー出力
セグフォする実行ファイルa.out
を実行すると
current
- execveの終了ステータスを見る
- シグナルで終わっていることを確認
- 終了ステータスを設定
ideal
- execveの終了ステータスを見る
- シグナルで終わっていることを確認
- シグナルの種類を判定して, 適切なエラー内容を出力(ただbashはstderr以外で出力してるらしく詳しくは謎)
WTERMSIG(wstatus)==SEGV
などの条件分岐で実装 - 終了ステータスを設定
例
$ ./a.out
minishell: segmentation fault ./a.out //<-ここ追加
$ echo $?
139
Ctrl+Dで終了するときのステータスを直前のステータスに直す。
getcwdとchdirのラボを開催します。
ラボ、始まるよ〜
- getcwdを実験しました。
- chdirを実験しました。
ノーム対応とコメント追記
execute.hとsrcsの僕の作ったファイル全部やります。
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.