Closed syamashi closed 3 years ago
minishell$ $A
minishell: Permission denied
minishell$ echo $?
126
c1r1s6% bash
bash-3.2$ $A
bash-3.2$ echo $?
0
NULLを与えても同様。
これは、セグフォでした。
minishell$ $AAAAA
==194== Invalid read of size 1
==194== at 0x1123C7: ft_memcpy (in /mnt/c/Users/shojiro/Desktop/42/minishell/git/minishell)
==194== by 0x10E527: make_path (ft_execvpe.c:26)
==194== by 0x10E681: sh_execvpe (ft_execvpe.c:47)
==194== by 0x10FEA8: sh_execvpes (sh_launch_utils.c:17)
==194== by 0x11020F: sh_launch_child (sh_launch.c:61)
==194== by 0x1102C7: sh_process_manager (sh_launch.c:86)
==194== by 0x1104D0: sh_launch (sh_launch.c:117)
==194== by 0x10A7A1: minishell (minishell.c:107)
==194== by 0x109444: main (main.c:19)
==194== Address 0x0 is not stack'd, malloc'd or (recently) free'd
コマンドがNULLだったらexecに入らずreturn 0。中断はしない。 ‘‘‘ $A | echo aaa aaa
bash-3.2$ $adfa | echo aaa |aaa bash: aaa: command not found bash-3.2$ echo $? 127
になる。
fix https://github.com/syamashi/minishell/commit/b7df3a70cbaf1d27d992034f7be521cc543636e4
command not foundにならず、
minishell$ $dffaio | echo aaa | aaa
minishell: No such file or directory
minishell$ echo $?
127
は別issue
fsanitize=addressをつけると、何も表示されないので、どちらも不一致。