FreddyMSchubert / 42_minishell

Basic bash-esque shell 🐢 ~ because communicating with computers using aligned 1/0 switches is seriously irritating. 🤬 [42 PROJECT]
1 stars 0 forks source link

pipes executing simultaneously creates weird behaviors #13

Closed FreddyMSchubert closed 5 months ago

FreddyMSchubert commented 5 months ago

Since we execute pipes at the same time, a lot of stuff can go wrong. Instead, lets do it like many other 42 folks have done it, and execute them linearly. This is technically not a perfect bash recreation but honestly who cares. It would greatly simplify the code and logic and we wouldn't have to fix many of the issues that are arising at the moment, that's worth it.

FreddyMSchubert commented 5 months ago

the pipes are now sequential. however, the execution is no longer exactly as wanted, as the following case we still print everything after each other. /bin/echo <123 <456 hi | /bin/echo 42 what should happen is that we should go back up the tree once we receive a negative return code (continuing with NULL if we are in a pipe) and only continue executing something else if we encounter a || operator while doing so. i am also not sure why our first error is

minishell$ /bin/echo <123 <456 hi | /bin/echo 42
minishell: <: No such file or directory
[...]

where in bash it is

bash-3.2$ /bin/echo <123 <456 hi | /bin/echo 42
bash: 123: No such file or directory
42
[...]
FreddyMSchubert commented 5 months ago

i have made it work and fixed up the mstest inputting (as its non-tty it didnt work before), but a lot of cases fail due to segfaults and stuff like that

FreddyMSchubert commented 5 months ago

given that in my understanding this can also happen in bash and we can avoid it to some extent by always using the default printf implementation and not our own custom which doesnt save into a buffer and is basically just an advanced write call, i guess were not doing this. alright.