TR-42 / minishell

https://tr-42.github.io/minishell/
0 stars 0 forks source link

DQUOTE内で変数直後にSPCが存在する場合、SPCが無視される #41

Closed TetsuOtter closed 1 year ago

TetsuOtter commented 1 year ago
% ./obj/test_serializer '$ABC  $ABC'

argv[1]: '$ABC  $ABC'
cmd[0] ~~~~~~~~~~~~~~~~~~ (isValid?: CMD_INVAL_NO_ERR at 1)
        elem[ 0]:    CMDTYP_VARIABLE 'ABC'(1 .. 3) -> spc:0
        elem[ 1]:    CMDTYP_VARIABLE 'ABC'(7 .. 3) -> spc:0
                (AGRC: 2 / isValid?: CMD_INVAL_NO_ERR)
% ./obj/test_serializer '$ABC-$ABC'

argv[1]: '$ABC-$ABC'
cmd[0] ~~~~~~~~~~~~~~~~~~ (isValid?: CMD_INVAL_NO_ERR at 1)
        elem[ 0]:    CMDTYP_VARIABLE 'ABC'(1 .. 3) -> spc:1
        elem[ 1]:      CMDTYP_NORMAL '-'(4 .. 1) -> spc:1
        elem[ 2]:    CMDTYP_VARIABLE 'ABC'(6 .. 3) -> spc:0
                (AGRC: 1 / isValid?: CMD_INVAL_NO_ERR)
TetsuOtter commented 1 year ago

そもそもテストの方法が間違ってた。 DQUOTEで囲んだつもりが、囲ってなかっただけだったっぽい?

tetsu@TRs-MacBook-Pro:~/ftgit/minishell% ./obj/test_serializer '"$ABC  $ABC"' 

argv[1]: '"$ABC  $ABC"'
cmd[0] ~~~~~~~~~~~~~~~~~~ (isValid?: CMD_INVAL_NO_ERR at 1)
        elem[ 0]:   CMDTYP_QUOTE_VAR 'ABC'(2 .. 3) -> spc:1
        elem[ 1]:      CMDTYP_NORMAL '  '(5 .. 2) -> spc:1
        elem[ 2]:   CMDTYP_QUOTE_VAR 'ABC'(8 .. 3) -> spc:0
                (AGRC: 1 / isValid?: CMD_INVAL_NO_ERR)
tetsu@TRs-MacBook-Pro:~/ftgit/minishell% ./minishell -c 'ls "$USER   $USER"'       
ls: tetsu   tetsu: No such file or directory
tetsu@TRs-MacBook-Pro:~/ftgit/minishell% ./minishell -c 'ls "$ABC   $ABC"'  
ls: abc def   abc def: No such file or directory
tetsu@TRs-MacBook-Pro:~/ftgit/minishell% ./minishell -c 'ls $ABC"   $ABC"'
ls: abc: No such file or directory
ls: def   abc def: No such file or directory