42/minishell.git
16 months agoRemove redirections from the environment
Lukas Jiriste [Thu, 1 Aug 2024 13:43:26 +0000 (15:43 +0200)]
Remove redirections from the environment

The redirections got handled in another way so this is not needed.

16 months agoMake operators < and << work
Lukas Jiriste [Thu, 1 Aug 2024 13:40:26 +0000 (15:40 +0200)]
Make operators < and << work

There was a minor confusion when the redirection was first implemented
because the usage was not yet thought about much.

16 months agoImplement redirection duping
Lukas Jiriste [Thu, 1 Aug 2024 13:28:59 +0000 (15:28 +0200)]
Implement redirection duping

16 months agoLet environment be inhereted by child processes
Lukas Jiriste [Thu, 1 Aug 2024 13:05:00 +0000 (15:05 +0200)]
Let environment be inhereted by child processes

By implementing add_exported function.

16 months agoImplement pipe duping
Lukas Jiriste [Thu, 1 Aug 2024 12:34:30 +0000 (14:34 +0200)]
Implement pipe duping

The order of closing the ends of pipes in ex_pipeline is done because
the reading end does not receive the eof unless the writting end is
closed. That means all file descriptors pointing to the writting end
have to be closed.
If the minishell itself only closes it after execution of the second
part of a pipe, it gets deadlocked, because minishell waits for the
process end to close the pipe and the process waits for the pipe to be
closed to exit.

16 months agoAllow execve to run
Lukas Jiriste [Thu, 1 Aug 2024 11:48:15 +0000 (13:48 +0200)]
Allow execve to run

This is done to test the implementation so far. Piping, redirections
and proper environment variables passing has to e implemented.

16 months agoFix not closing DIR
Lukas Jiriste [Thu, 1 Aug 2024 11:47:16 +0000 (13:47 +0200)]
Fix not closing DIR

16 months agoAdd the possibility to specify path to executable
Lukas Jiriste [Thu, 1 Aug 2024 11:05:33 +0000 (13:05 +0200)]
Add the possibility to specify path to executable

Before only the PATH was examined, now the field itself may contain the
path and minishell will recognize it.

16 months agoFix fields always ending with empty string
Lukas Jiriste [Thu, 1 Aug 2024 10:07:42 +0000 (12:07 +0200)]
Fix fields always ending with empty string

16 months agoUpdate Libft for a fix of invalid read in ft_split
Lukas Jiriste [Thu, 1 Aug 2024 10:06:34 +0000 (12:06 +0200)]
Update Libft for a fix of invalid read in ft_split

16 months agoAdd the structure of ex_fields, implement find_exe
Lukas Jiriste [Thu, 1 Aug 2024 10:02:07 +0000 (12:02 +0200)]
Add the structure of ex_fields, implement find_exe

The find_exe goes through the PATH variable of environment and looks
whether any of the directories contains the executable entered.

16 months agoFix here file delimiter recognition
Lukas Jiriste [Thu, 1 Aug 2024 07:52:57 +0000 (09:52 +0200)]
Fix here file delimiter recognition

Because the input line always contains newline character, it has to only
be compared to the last but one character.

16 months agoFix not freeing filename
Lukas Jiriste [Thu, 1 Aug 2024 07:48:48 +0000 (09:48 +0200)]
Fix not freeing filename

16 months agoMake sure t_vecs are initialized before free
Lukas Jiriste [Thu, 1 Aug 2024 07:30:06 +0000 (09:30 +0200)]
Make sure t_vecs are initialized before free

Short circuiting was meant to save the computation resources but causes
assignments not to be initialized when redirections encounter a problem.
This could be solved by initializing assignments outside of
save_assignments or by letting save_assignments initialize the
assignments even though it won't be used. I opted for the later.

16 months agoFix missing terminator null in assignment
Lukas Jiriste [Mon, 22 Jul 2024 20:55:40 +0000 (22:55 +0200)]
Fix missing terminator null in assignment

Instead there of terminating null there was a space left by the add_word
function. That also caused wrong concatenation of chained var expansions

16 months agoRemove interpreting unclosed quotes and \
Lukas Jiriste [Mon, 22 Jul 2024 20:43:19 +0000 (22:43 +0200)]
Remove interpreting unclosed quotes and \

As per the subject those should not be handled. Hence it is removed from
the tokenizer.

16 months agoAdd var expansion and quote handling to assignment
Lukas Jiriste [Mon, 22 Jul 2024 20:30:40 +0000 (22:30 +0200)]
Add var expansion and quote handling to assignment

It is a little ugly because I adapted the machinery that handles the
expansion and quote handling of fields. This may be rectified in future
refactor.

16 months agoHandle quotes in WORD tokens
Lukas Jiriste [Mon, 22 Jul 2024 20:14:17 +0000 (22:14 +0200)]
Handle quotes in WORD tokens

16 months agoFix the get_var_name name recognition logic
Lukas Jiriste [Mon, 22 Jul 2024 18:44:27 +0000 (20:44 +0200)]
Fix the get_var_name name recognition logic

16 months agoFix some minor issues
Lukas Jiriste [Sun, 21 Jul 2024 22:11:49 +0000 (00:11 +0200)]
Fix some minor issues

Of by one errors, missing free and such.

16 months agoAdd the rest of execution except for ex_fields
Lukas Jiriste [Sun, 21 Jul 2024 19:46:24 +0000 (21:46 +0200)]
Add the rest of execution except for ex_fields

This commit makes the project compilable (though it crashes).
It implements the small missing functions in execution.c and integrates
it into the project.

16 months agoUpdate Libft fot ft_swap_int
Lukas Jiriste [Sun, 21 Jul 2024 19:45:06 +0000 (21:45 +0200)]
Update Libft fot ft_swap_int

16 months agoFix change in ft_split signature.
Lukas Jiriste [Sun, 21 Jul 2024 18:32:16 +0000 (20:32 +0200)]
Fix change in ft_split signature.

16 months agoUpdate Libft for some new t_vec functions
Lukas Jiriste [Sun, 21 Jul 2024 18:31:10 +0000 (20:31 +0200)]
Update Libft for some new t_vec functions

16 months agoAdd the actual split to fields
Lukas Jiriste [Sun, 21 Jul 2024 17:56:18 +0000 (19:56 +0200)]
Add the actual split to fields

I forgot to implement it 2 commits back and compiler does not warn
because the vec is void pointer.

16 months agoFix minor issues
Lukas Jiriste [Sun, 21 Jul 2024 17:47:53 +0000 (19:47 +0200)]
Fix minor issues

16 months agoImplement expansion inside execution.c
Lukas Jiriste [Sun, 21 Jul 2024 17:40:50 +0000 (19:40 +0200)]
Implement expansion inside execution.c

Due to that the expansion.c file is removed.

16 months agoResort to returning const char ptrs to values
Lukas Jiriste [Sun, 21 Jul 2024 16:25:36 +0000 (18:25 +0200)]
Resort to returning const char ptrs to values

This makes the get_env_var_value unable to fail and the value does not
eed to be changed though pointer, the variable definition as a whole is
replaced during redefinition.

16 months agoAdd is_token_type function
Lukas Jiriste [Sun, 21 Jul 2024 16:19:51 +0000 (18:19 +0200)]
Add is_token_type function

16 months agoAdd the save_redirections function
Lukas Jiriste [Sun, 21 Jul 2024 15:44:24 +0000 (17:44 +0200)]
Add the save_redirections function

This function traverses the command prefix and suffix, opens all the
files needed for redirection and saves the information to a t_vec.

16 months agoAdd save_assignments function
Lukas Jiriste [Sun, 21 Jul 2024 12:24:50 +0000 (14:24 +0200)]
Add save_assignments function

This function traverses the subtree of the command and extracts all
ASSIGNMENT_WORD tokens to the assignments t_vec so that it is in the
same form as the t_vecs in t_vars.

16 months agoAdd check for unsuccessful execution
Lukas Jiriste [Sun, 21 Jul 2024 11:12:10 +0000 (13:12 +0200)]
Add check for unsuccessful execution

Add some checks inside ex_simple_command.

16 months agoRename t_execution_info, add its definition
Lukas Jiriste [Sun, 21 Jul 2024 11:03:31 +0000 (13:03 +0200)]
Rename t_execution_info, add its definition

16 months agoMake some small changes
Lukas Jiriste [Sun, 21 Jul 2024 10:59:53 +0000 (12:59 +0200)]
Make some small changes

16 months agoRefactor the subshell execution
Lukas Jiriste [Sun, 21 Jul 2024 10:58:56 +0000 (12:58 +0200)]
Refactor the subshell execution

16 months agoAdd and outline for the tree execution.
Lukas Jiriste [Sun, 21 Jul 2024 07:10:44 +0000 (09:10 +0200)]
Add and outline for the tree execution.

16 months agoUpdate Libft for the Norm compliance
Lukas Jiriste [Sun, 21 Jul 2024 06:54:22 +0000 (08:54 +0200)]
Update Libft for the Norm compliance

16 months agoSimplify the about_grammmar
Lukas Jiriste [Fri, 19 Jul 2024 14:19:52 +0000 (16:19 +0200)]
Simplify the about_grammmar

This is possible thanks to the grammar of minishell being simpler than
that of shell.

16 months agoReplace the parsing table with a correct one
Lukas Jiriste [Fri, 19 Jul 2024 14:08:23 +0000 (16:08 +0200)]
Replace the parsing table with a correct one

Also update the rules to fit with the new table.

17 months agoFix leak.
Lukas Jiriste [Thu, 27 Jun 2024 07:34:52 +0000 (09:34 +0200)]
Fix leak.

The handle_input function could be structured better to not make
mistakes such as the one that is fixed by this comment.

17 months agoUpdate Libft for better parse_tree printing
Lukas Jiriste [Thu, 27 Jun 2024 07:15:44 +0000 (09:15 +0200)]
Update Libft for better parse_tree printing

17 months agoFix quote handling during tokenization
Lukas Jiriste [Thu, 27 Jun 2024 07:15:31 +0000 (09:15 +0200)]
Fix quote handling during tokenization

17 months agoImplement tokenization
Lukas Jiriste [Sun, 23 Jun 2024 17:08:37 +0000 (19:08 +0200)]
Implement tokenization

The tokenization seems to work now. Thanks to it the parsing can be
tested which shows a leak with the unfreed memory originating from the
follow_rule function.

17 months agoChange the file structure of the project
Lukas Jiriste [Fri, 21 Jun 2024 15:02:05 +0000 (17:02 +0200)]
Change the file structure of the project

Because the parsing was implemented inside libft the parsingh was not
needed here. The informative contents were moved to about_grammar.

The variable expansion and tokenization were given their own files.

17 months agoUpdate Libft for parsing support
Lukas Jiriste [Fri, 21 Jun 2024 13:57:14 +0000 (15:57 +0200)]
Update Libft for parsing support

17 months agoAdd grammar rules and parsing table for minishell
Lukas Jiriste [Fri, 21 Jun 2024 13:56:52 +0000 (15:56 +0200)]
Add grammar rules and parsing table for minishell

17 months agoRepair problems caused by change 2 commit back
Lukas Jiriste [Fri, 14 Jun 2024 09:03:26 +0000 (11:03 +0200)]
Repair problems caused by change 2 commit back

The change made was from t_vec<char> to char *.
This change was not made in the function handeling tokens however,
which is rectified with this commit.

The previous 2 commit were made quickly as an exercise in using git
hence the low quality.

17 months agoAdd a comment
Lilia-42 [Fri, 14 Jun 2024 08:34:18 +0000 (10:34 +0200)]
Add a comment

17 months agoChange char * as it is easier to understand
Lukas Jiriste [Fri, 14 Jun 2024 08:30:59 +0000 (10:30 +0200)]
Change char * as it is easier to understand

19 months agoCreate the structure for input handling
Lukas Jiriste [Fri, 3 May 2024 14:11:26 +0000 (16:11 +0200)]
Create the structure for input handling

Create prototypes of some needed types (token, parse tree) and
create the structure of the input processing with empty functions.

Also add a grammar for minishell inside a comment in parsing.h.
This is a simplification of the grammar of Shell programming language
as it is laid out inside
The Open Group Base Specifications Issue 7, 2018 edition
Chapter 2. Shell Command Language
found on site
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html

19 months agoRename almost_empty to is_almost_empty
Lukas Jiriste [Fri, 3 May 2024 06:58:45 +0000 (08:58 +0200)]
Rename almost_empty to is_almost_empty

19 months agoAdd version without history
Lukas Jiriste [Thu, 2 May 2024 12:40:05 +0000 (14:40 +0200)]
Add version without history

This version doesn't utilize GNU Readline so it has much lower memory
footprint. The main benefit however is that tracking with valgrind is
made easier with this.

19 months agoImplement variables framework, update Libft
Lukas Jiriste [Thu, 2 May 2024 11:27:09 +0000 (13:27 +0200)]
Implement variables framework, update Libft

So far the variable handling consists of copying the environment
inherited by minishell to separate variable to make changes to it
possible (I suspect that one should not directly change the environ).

The vars struct consists of 2 vectos of strings, one for the exported
variables and one for the others.
This is done so that the exported->vec can be directly passed to execve
instead of contructing it by filtering the exported values from
a common vector.
This is also why the vector is initialized with NULL. The other vec
is constructed the same way so as to be able to reuse the code for
exported.

During work on this commit the function ft_strcat_alloc seemed to be
a great candidate for  addition to Libft. That was done and the
function was used in this commit, hence the Libft update.

19 months agoImplement exitable skeleton of a shell
Lukas Jiriste [Fri, 26 Apr 2024 12:03:25 +0000 (14:03 +0200)]
Implement exitable skeleton of a shell

The minishell is now able to accept input and access history through
the GNU Readline library.
The minishell itself prints prompt with currect directory.
It also handles the "exit" command as well as ctrl-D
so that it can exit. It prints "exit" on exit like bash.

19 months agoCreate the foundations for minishell
Lukas Jiriste [Fri, 26 Apr 2024 11:15:23 +0000 (13:15 +0200)]
Create the foundations for minishell

First commit contains .gitignore, Makefile and an empty main.c.
I also added Libft as a submodule, because I'll certainly use it.