minishellakirawchen / minishell_rev1

Rewrite and challenge bonus requirement
1 stars 1 forks source link

#23 Test #23

Closed ak0327 closed 1 year ago

ak0327 commented 1 year ago
 while [ 1 ]; do leaks -q minishell; sleep 1; done
ak0327 commented 1 year ago

*~cat | cat | ls ができなくなっている~

修正完了

ak0327 commented 1 year ago
ak0327 commented 1 year ago

~ minishell $> <<~ ~ minishell: syntax error near unexpected token <<'~ ~* bash: syntax error near unexpected tokennewline'~

修正完了 @ #26 https://github.com/minishellakirawchen/minishell_rev1/commit/270358df8fd2b4eb6beb5c3e7b9ea7e9e626c99a

ak0327 commented 1 year ago
ak0327 commented 1 year ago

* export c=$PATH -> minishell: export: `Support/(略) ': not a valid identifier * PATHにspaceがあると分解されて渡されているみたい?問題ないか見直す 以下にて解決

ak0327 commented 1 year ago

* export a="hello world"; export b=$aの際、$a="hello", "world"で渡されるためb=hello, worldはerrorとなる。bashは$b="hello world"として登録 * echo $a{"echo" "hello", "world"}として振る舞っているのに...?assignmentで挙動が変わるのか?それはめんどい。保留 * ワイルドカードと同じように、exportの時にre tokenizeしないようにできそう

bash3.2_2[0] $ export a="hello        world"
bash3.2_2[0] $ export b=$a
bash3.2_2[0] $ export c="export d=$a"
bash3.2_2[0] $ echo $a  //hello world
bash3.2_2[0] $ echo $b  //hello world
bash3.2_2[0] $ echo $c  //export d=hello world
bash3.2_2[0] $ echo $d  //
bash3.2_2[0] $ $c
bash3.2_2[0] $ echo $c  //export d=hello world
bash3.2_2[0] $ echo $d  //hello  <- "hello"までしか登録されていない

* re tokenizeするときに先頭がexportであればre tokenizeしなければよさそう * これで $dの挙動も再現できる * "export d=hello world"のような塊で来た時には分割できる

対応完了! heredocでも同様の展開になっていて。対応しておいてよかった。

ak0327 commented 1 year ago

使用可能関数:問題なし(memcpyが呼ばれているが探せない。コンパイラの仕業?)

ak0327 commented 1 year ago

ここまでの変更分をmianへmerge

ak0327 commented 1 year ago

Feb/6th test

exit

bash-3.2-2 255 $ exit 1 | exit 2 | exit 3
bash-3.2-2 3 $ 

複数のケースで終了しない exit出力しない

heredoc

quote expansion

export

cd

ak0327 commented 1 year ago

quote expasion, heredoc, exitは #28 で修正する -> 完了

ak0327 commented 1 year ago

Feb/7th test

command execution

bash3.2_3[0] $ unset PATH
bash3.2_3[0] $ ls in1
in1dayo
bash3.2_3[0] $ ./ls in1
in1dayo
bash3.2_3[0] $ /bin/ls
dir             dir2            in1             in3             ls              ou2             out2

minishell 0 $> unset PATH
minishell 0 $> ls in1
minishell: ls: command not found
minishell 127 $> ./ls in1
in1dayo
minishell 0 $> /bin/ls
dir             dir2            in1             in3             ls              ou2             out2

exit

cd

weijuan82113 commented 1 year ago

Feb/7th test

command execution

  • unset PATH でのコマンド実行
  • minishellはcommand not found, bashはcurrentを実行
  • current dirのlsはcatをcopyしてrenameした
bash3.2_3[0] $ unset PATH
bash3.2_3[0] $ ls in1
in1dayo
bash3.2_3[0] $ ./ls in1
in1dayo
bash3.2_3[0] $ /bin/ls
dir             dir2            in1             in3             ls              ou2             out2

minishell 0 $> unset PATH
minishell 0 $> ls in1
minishell: ls: command not found
minishell 127 $> ./ls in1
in1dayo
minishell 0 $> /bin/ls
dir             dir2            in1             in3             ls              ou2             out2

exit

  • exit引数なしはstatusを保持したままexitが正しい挙動

    • ex) syntaxerror 258 -> exitでstatusは2
    • ex)^C 1 -> exit でstatusは1

→修正修正済み

cd

  • cd nothing はstatusを1に変更する

→修正修正済み

weijuan82113 commented 1 year ago

Feb/6th test

exit

bash-3.2-2 255 $ exit 1 | exit 2 | exit 3
bash-3.2-2 3 $ 

複数のケースで終了しない exit出力しない

heredoc

  • eof後に改行し出力される

quote expansion

  • quote expansionの挙動が異なる
bash-3.2-2 0 $ "$c"
bash: "echo    hello     world": command not found
bash-3.2-2 127 $ 
bash-3.2-2 127 $ 
bash-3.2-2 127 $ $c
bash: "echo: command not found

export

  • export +=testでエラーが出ない

→修正済み

bash-3.2-2 0 $ export abc +=test
bash: export: `+=test': not a valid identifier

→修正済み

cd

  • leaks
  • cd PATH遷移後のcd -OLDPWD=NULLになる

→修正済み

ak0327 commented 1 year ago

Feb/8th test

~redirect & signal~ -> 完了?? 取り掛かろうと思ったら再現できず。他の修正でいじった影響か?テスト前に環境に変なことしたかも?再発が怖い

// これはOK minishell 0 $> echo hello > out

// NG minishell 0 $> <<end

hoge end Interrupt by signal : 11

// これはOK minishell 0 $> cat <<end

hoge end hoge minishell 0 $>


&& || -> 完了

bash3.2_2[0] $ echo 1 && echo 2 || echo 3 || echo 4 && echo 5
1
2
5

minishell 0 $> echo 1 && echo 2 || echo 3 || echo 4 && echo 5
1
2




以降、テストケース参考元 https://github.com/nafuka11/42_minishell_tester


cd


echo


~exit~ -> 完了

bash3.2_4[0] $ exit -- 42 exit bash3.2_3[42] $


*  ~符号のみ ...............................................................................**(5)**~ -> 完了
  * ~これはstrtolの修正~
```shell
minishell 0 $> exit +
exit
bash3.2_2[0] $ 

bash3.2_3[0] $ exit +
exit
bash: exit: +: numeric argument required
bash3.2_2[255] $ 


// exitしないらしい(shlvl=5のまま) bash3.2_5[0] $ exit 0 0; exit exit bash: exit: too many arguments bash3.2_5[1] $


<br>

## expand
* OK

<br>

## export 
* OK

<br>

## path
* OK

<br>

## pwd
* shell立ち上げてすぐの`$OLDPDW=NULL`
* テスト全てやっていないので他にもあるかも
```shell
takira % ./minishell 
minishell 0 $> echo $OLDPWD
/Users/akira/Documents/Programming/CLionProjects/42/42cursus/03_minishell_rev1
minishell 0 $> 

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
bash3.2_6[0] $ echo $OLDPWD

bash3.2_6[0] $


redirect


~simple command~ -> 完了

bash3.2_6[0] $ no_such_file bash: no_such_file: command not found bash3.2_6[127] $ ./no_such_file bash: ./no_such_file: No such file or directory bash3.2_6[127] $ /bin/ls/no_such_file bash: /bin/ls/no_such_file: Not a directory


<br>

* ~`$nothing`単独の場合はcommand not foundにしない ..................................**(6)**~ ->完了

```shell
minishell 127 $> echo a | $NO_ENV 
minishell: : command not found
minishell 127 $> 

bash3.2_6[1] $ echo a | $NO_ENV 
bash3.2_6[0] $ 


~syntax error~ -> 完了

~* エラー文が異なる~

// semicolon
minishell 258 $> ;;
minishell: syntax error near unexpected token `;;'
minishell 258 $> ;;;
minishell: syntax error near unexpected token `;;;'
minishell 258 $> ;;;;
minishell: syntax error near unexpected token `;;;;'

bash: syntax error near unexpected token `;;'
bash3.2_6[258] $ ;;;
bash: syntax error near unexpected token `;;'
bash3.2_6[258] $ ;;;;
bash: syntax error near unexpected token `;;'

// redirection >
minishell 258 $> >>>
minishell: syntax error near unexpected token `>>>'
minishell 258 $> >>>>
minishell: syntax error near unexpected token `>>>>'

bash3.2_6[258] $ >>>
bash: syntax error near unexpected token `>'
bash3.2_6[258] $ >>>>
bash: syntax error near unexpected token `>>'

// redirection < >
minishell 258 $> < >
minishell: syntax error near unexpected token `newline'

bash3.2_6[258] $ < >
bash: syntax error near unexpected token `>'

// redirection command  < >
minishell 258 $> cat < >
minishell: syntax error near unexpected token `newline'

bash3.2_6[258] $ cat < >
bash: syntax error near unexpected token `>'
bash3.2_6[258] $ 


unset


ak0327 commented 1 year ago

(())はsubshellではなく算術演算の展開らしい 対応する必要なさそう (())はsyntax errorに戻す

ak0327 commented 1 year ago
ak0327 commented 1 year ago
ak0327 commented 1 year ago
ak0327 commented 1 year ago
ak0327 commented 1 year ago

leaks rm -rf dir -> cd ..

ak0327 commented 1 year ago
ak0327 commented 1 year ago

<in1 cat | >out1 <<a

ak0327 commented 1 year ago

Feb/9th test


<br>

* ~interrupt by signal~  -> とりあえず対応完了 分岐は維持したままerror msgのprintを削除した
``` shell
minishell 0 $> echo 0 && (echo 1 | echo 2 && echo 3) | echo 4 | echo 5
0
5
Interrupt by signal : 13
ak0327 commented 1 year ago

cd


minishell 0 $> cd ngdir
minishell 0 $> 
minishell 0 $> pwd
/Users/akira/Documents/Programming/CLionProjects/42/42cursus/03_minishell_rev1/testdir

bash3.2_4[0] $ cd ngdir/
bash: cd: ngdir/: Permission denied
bash3.2_4[1] $ 


ak0327 commented 1 year ago
minishell 0 $> ls
dir__   dir__x  dir_r_  dir_rx
minishell 0 $> cd dir_r_
minishell 0 $> pwd
/Users/akira/Documents/Programming/CLionProjects/42/42cursus/03_minishell_rev1/dir
minishell 0 $> 

bash3.2_2[0] $ cd dir_r_
bash: cd: dir_r_: Permission denied
bash3.2_2[1] $