mahahahad / Minishell

1 stars 1 forks source link

feat: wildcards now expand to the files in the cwd #23

Closed Ali-Danish-72 closed 2 months ago

Ali-Danish-72 commented 2 months ago

For every token of type WORD, I check for a [ * ]. Three system calls are used mainly to identify and match file names with the token. It ensures that the hidden files are ignored unless specified.

To achieve the complex pattern matching, I recursively call the function responsible for it with updated arguments, so that it essentially matches the leading characters. If the pattern needs a comparison of the trailing chararacters, I use the ft_strncmp() function for that match.

While testing, I came across a bug in the dollar expansion section. The expansion would ignoring everything after a [ ' ] regardless of it being nested within [ " " ] or whether or not there was a closing [ ' ]. This is now rectified.

Ali-Danish-72 commented 2 months ago

Note that there is a while loop condition that I changed in the match_pattern() function. The condition is for the second while loop. I had originally placed it to fix a certain bug but I am failing to recall the case that had caused that bug. So I request further intensive testing to ensure that this is not breaking.