WSSMRKS / 42_minishell

Minishell Team Project @ 42 Berlin
2 stars 1 forks source link

Segfault when running redirects without actual command. #8

Open WSSMRKS opened 1 week ago

WSSMRKS commented 1 week ago

Segfault when redirects without commands.

wssmrks@MarkusPC:~/42_minishell$ ./minishell minishell$ <in1 Segmentation fault (core dumped) wssmrks@MarkusPC:~/42_minishell$ ./minishell minishell$ <in1 <in2 <in3 Segmentation fault (core dumped) wssmrks@MarkusPC:~/42_minishell$ wssmrks@MarkusPC:~/42_minishell$ ./minishell minishell$ <in1 Segmentation fault (core dumped) wssmrks@MarkusPC:~/42_minishell$ ./minishell minishell$ <in1 <in2 <in3 Segmentation fault (core dumped) wssmrks@MarkusPC:~/42_minishell$ ./minishell minishell$ >o1 >o2 >o3 Segmentation fault (core dumped) wssmrks@MarkusPC:~/42_minishell$ dir Makefile headers ms_behavior.txt test todo create_rl_suppressions.sh libft src test_chdir.c todo.txt design_choices.txt minishell suppressions.supp testcases wssmrks@MarkusPC:~/42_minishell$ ./minishell minishell$ >o1 Segmentation fault (core dumped) wssmrks@MarkusPC:~/42_minishell$

WSSMRKS commented 7 hours ago

@kjzl Did you change something in the parser? those commands are not coming through to the executor anymore. Bash is giving these commands through and then executing creating or checking for the files. Implement or leave as is? For me both is fine.

Example:

wssmrks@wssmrks-desktop:~/coding/42_minishell$ <in1
bash: in1: No such file or directory
wssmrks@wssmrks-desktop:~/coding/42_minishell$ cat >in1
this is a file
wssmrks@wssmrks-desktop:~/coding/42_minishell$ <in1
wssmrks@wssmrks-desktop:~/coding/42_minishell$ >out
wssmrks@wssmrks-desktop:~/coding/42_minishell$ >>out2
wssmrks@wssmrks-desktop:~/coding/42_minishell$ ls -al
total 640
drwxrwxr-x  8 wssmrks wssmrks   4096 Nov 25 16:08 .
drwxrwxr-x  5 wssmrks wssmrks   4096 Nov 25 13:10 ..
drwxrwxr-x  8 wssmrks wssmrks   4096 Nov 25 15:59 .git
-rw-rw-r--  1 wssmrks wssmrks    273 Nov 17 21:28 .gitignore
drwxrwxr-x  2 wssmrks wssmrks   4096 Nov 18 23:44 .vscode
-rw-rw-r--  1 wssmrks wssmrks   3067 Nov 21 18:13 Makefile
-rwxrwxr-x  1 wssmrks wssmrks    514 Nov 18 23:44 create_rl_suppressions.sh
drwxrwxr-x  2 wssmrks wssmrks   4096 Nov 25 15:58 headers
-rw-rw-r--  1 wssmrks wssmrks     15 Nov 25 16:07 in1
drwxrwxr-x 18 wssmrks wssmrks   4096 Nov 25 16:04 libft
-rwxrwxr-x  1 wssmrks wssmrks 575496 Nov 25 16:04 minishell
-rw-rw-r--  1 wssmrks wssmrks      0 Nov 25 16:08 out
-rw-rw-r--  1 wssmrks wssmrks      0 Nov 25 16:01 out1
-rw-rw-r--  1 wssmrks wssmrks      0 Nov 25 16:08 out2
drwxrwxr-x  7 wssmrks wssmrks   4096 Nov 17 21:28 src
-rw-rw-r--  1 wssmrks wssmrks  54571 Nov 18 23:44 suppressions.supp
-rw-rw-r--  1 wssmrks wssmrks   1968 Nov 25 12:36 testcases
drwxrwxr-x  2 wssmrks wssmrks   4096 Nov 21 18:13 tests
wssmrks@wssmrks-desktop:~/coding/42_minishell$ 
kjzl commented 3 hours ago

Crashes with input without actual commands was fixed by commit 1503cdc. The parser returns NULL for input without a command to be run. Do we need to change this?

kjzl commented 3 hours ago

@WSSMRKS

WSSMRKS commented 3 hours ago

If we want to exactly rebuilt bash yes we need to change. Then a command like ">P1 >P2 >P3" would solely create the files And a command like "<In1 <In2" would only check if the files are there.

@kjzl What do you think?

kjzl commented 2 hours ago

Tracked by #57