taandreo / minishell

Minihell from 42. Everything is gonna be fine.
2 stars 1 forks source link

Parser Bonus (*) #11

Closed edu-bm7 closed 11 months ago

edu-bm7 commented 1 year ago

Wildcards * should work for the current working directory.

edu-bm7 commented 1 year ago

Right now I'm working on tokenizing the * as a separated token to be expanded during the parser phase so we know our current working directory for that part of the execution phase(if we changed directory in the middle of execution the * should be used in another directory, if it is after the cd command), so thats why we cant expand directly on the tokenizing phase.

edu-bm7 commented 1 year ago

The wild card tokenization part is done. Now we should leave the rest to the parser phase.

edu-bm7 commented 11 months ago

The expansion of the wildcards is completed, proceeding to test it

edu-bm7 commented 11 months ago

After extensively testing, the parser is working as expetected, here the tests that I did:

  1. Basic Wildcard Tests:
    • Files: abc.txt, axc.txt, a123c.txt, bc.txt, ac.txt, a.c.txt
    • Pattern: a*c.txt
    • Expected Matches: abc.txt, axc.txt, a123c.txt, ac.txt, a.c.txt
  2. Wildcard At The Beginning:
    • Files: file.txt, myfile.txt, yourfile.txt, afile.txt
    • Pattern: *file.txt
    • Expected Matches: All of them
  3. Wildcard At The End:
    • Files: notes.txt, notes.doc, notes.png, notes
    • Pattern: notes.*
    • Expected Matches: notes.txt, notes.doc, notes.png
  4. Wildcard At Both Ends:
    • Files: main.c, maintest.c, testmain.c, maintestmain.c
    • Pattern: main.c
    • Expected Matches: All of them
  5. Multiple Wildcards:
    • Files: a.txt, ab.txt, abc.txt, abcd.txt, abcde.txt
    • Pattern: abc*.txt
    • Expected Matches: abc.txt, abcd.txt, abcde.txt
  6. Only Wildcard:
    • Files: Any set of files
    • Pattern: *
    • Expected Matches: All files
  7. Consecutive Wildcards (Although rarely used in practice, it's a good edge case):
    • Files: a.txt, aa.txt, aaa.txt
    • Pattern: a**.txt
    • Expected Matches: All of them
  8. Wildcards with Special Characters:
    • Files: a$.txt, a$1.txt, a$$.txt, a$123.txt
    • Pattern: a$*.txt
    • Expected Matches: All of them
  9. No Matches:
    • Files: file1.txt, file2.txt
    • Pattern: file3.txt
    • Expected Matches: None
  10. Wildcard in Middle:
    • Files: file.txt, fileXtxt, fileXXtxt, fileYtxt
    • Pattern: file*txt
    • Expected Matches: All of them
  11. Edge Case with Multiple Wildcards:
    • Files: fileabcde.txt, filebcde.txt, filecde.txt, filede.txt, filee.txt
    • Pattern: fileabcd*e.txt
    • Expected Matches: fileabcde.txt
  12. Multiple Consecutive Wildcards:
    • Files: axb.txt, a.txt, ab.txt, a1234b.txt
    • Pattern: a***b.txt
    • Expected Matches: axb.txt, ab.txt, a1234b.txt
  13. No File Extension:
    • Files: document, doc, docu, documentary
    • Pattern: doc*
    • Expected Matches: All of them