codemindshub / liteshell

liteshell (lsh) is a lightweight and custom implementation of the Unix shell. It is designed to provide a minimalistic yet functional shell experience. With a focus on simplicity and ease of use, liteshell aims to be a versatile tool for command-line interactions.
5 stars 4 forks source link

Implement the command tokenizer #9

Open nanafox opened 11 months ago

nanafox commented 11 months ago

For this task, your job will be to break a string into the required substrings based on a given delimiter. This function must return a string array. The function to use is

#include "liteshell.h"

char **tokenize(const char *str, const char *delim);

This function will utilize the strtok function. Ensure you are handling memory correctly and checking for edge cases. This function will be what everyone will use for anything that requires tokenization for the entire shell. For this reason, ensure you are thinking outside of the box and bringing out something very efficient and long-lasting.

When delimiter is NULL, assume spaces and tabs. Also, terminate the array before returning it.

Example usage:

int i;
char *cmd = "Hello world";

/* call the function to tokenize on spaces */
char **cmd_array = tokenized(cmd, NULL);

/* print the array */
for (i = 0; cmd_array[i] != NULL; i++)
    printf("%s\n");

Expected output:

Hello
World

File: lsh_utils.c

akoredera commented 11 months ago

@LawsonLawson @Kofi-Awuah2020... Good morning, I trust your night was awesome. The task has been rolled out for us to tackle, I hope we get it done between today and tomorrow, may I know our schedule so that we have our first discussion and share ideas of how we do the task. Looking forward to hearing from you

OmondiHillaryA1997 commented 11 months ago

Good Morning too Rid, I appreciate you contacting us.

Allow me share my Weekly schedule unless things change.

Monday to Friday: 11:30Am to 9PM EAT I attend to part time work. Monday to Friday: Morning hours before 11 AM EAT attend to ALX_SE Curriculum Saturday and Saturday: Fixtures are made depending on how the week has been but having this Collaboration going beyond Codemind Schedule can be beneficial.

Roughly, that how my Weekly Sketch looks like. Regards.

On Mon, Dec 4, 2023 at 8:10 AM AKOREDE RIDWANULLAHI ABIODUN < @.***> wrote:

@LawsonLawson https://github.com/LawsonLawson @Kofi-Awuah2020 https://github.com/Kofi-Awuah2020... Good morning, I trust your night was awesome. The task has been rolled out for us to tackle, I hope we get it done between today and tomorrow, may I know our schedule so that we have our first discussion and share ideas of how we do the task. Looking forward to hearing from you

— Reply to this email directly, view it on GitHub https://github.com/codemindshub/liteshell/issues/9#issuecomment-1837853185, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6FJC5LIW3WQU6POP27BKIDYHVLLBAVCNFSM6AAAAABAFEFBY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZXHA2TGMJYGU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

OmondiHillaryA1997 commented 11 months ago

Probably, Today at 10 PM to 12 PM EAT or Tuesday 7 AM to 10 AM EAT can work for me but stil flexible to reschedule.

On Mon, Dec 4, 2023 at 8:34 AM omondi hillary @.***> wrote:

Good Morning too Rid, I appreciate you contacting us.

Allow me share my Weekly schedule unless things change.

Monday to Friday: 11:30Am to 9PM EAT I attend to part time work. Monday to Friday: Morning hours before 11 AM EAT attend to ALX_SE Curriculum Saturday and Saturday: Fixtures are made depending on how the week has been but having this Collaboration going beyond Codemind Schedule can be beneficial.

Roughly, that how my Weekly Sketch looks like. Regards.

On Mon, Dec 4, 2023 at 8:10 AM AKOREDE RIDWANULLAHI ABIODUN < @.***> wrote:

@LawsonLawson https://github.com/LawsonLawson @Kofi-Awuah2020 https://github.com/Kofi-Awuah2020... Good morning, I trust your night was awesome. The task has been rolled out for us to tackle, I hope we get it done between today and tomorrow, may I know our schedule so that we have our first discussion and share ideas of how we do the task. Looking forward to hearing from you

— Reply to this email directly, view it on GitHub https://github.com/codemindshub/liteshell/issues/9#issuecomment-1837853185, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6FJC5LIW3WQU6POP27BKIDYHVLLBAVCNFSM6AAAAABAFEFBY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZXHA2TGMJYGU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Likeness30 commented 11 months ago

Good morning all I think it will be fine if we as a team we have our first call today and then discuss the way forward Thank you

Best regard.

On Mon, Dec 4, 2023, 6:41 AM OmondiHillaryA @.***> wrote:

Probably, Today at 10 PM to 12 PM EAT or Tuesday 7 AM to 10 AM EAT can work for me but stil flexible to reschedule.

On Mon, Dec 4, 2023 at 8:34 AM omondi hillary @.***> wrote:

Good Morning too Rid, I appreciate you contacting us.

Allow me share my Weekly schedule unless things change.

Monday to Friday: 11:30Am to 9PM EAT I attend to part time work. Monday to Friday: Morning hours before 11 AM EAT attend to ALX_SE Curriculum Saturday and Saturday: Fixtures are made depending on how the week has been but having this Collaboration going beyond Codemind Schedule can be beneficial.

Roughly, that how my Weekly Sketch looks like. Regards.

On Mon, Dec 4, 2023 at 8:10 AM AKOREDE RIDWANULLAHI ABIODUN < @.***> wrote:

@LawsonLawson https://github.com/LawsonLawson @Kofi-Awuah2020 https://github.com/Kofi-Awuah2020... Good morning, I trust your night was awesome. The task has been rolled out for us to tackle, I hope we get it done between today and tomorrow, may I know our schedule so that we have our first discussion and share ideas of how we do the task. Looking forward to hearing from you

— Reply to this email directly, view it on GitHub < https://github.com/codemindshub/liteshell/issues/9#issuecomment-1837853185>,

or unsubscribe < https://github.com/notifications/unsubscribe-auth/A6FJC5LIW3WQU6POP27BKIDYHVLLBAVCNFSM6AAAAABAFEFBY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZXHA2TGMJYGU>

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/codemindshub/liteshell/issues/9#issuecomment-1837879498, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMSUMFEFJGL3LS7D24OMJYLYHVPBDAVCNFSM6AAAAABAFEFBY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZXHA3TSNBZHA . You are receiving this because you were assigned.Message ID: @.***>

OmondiHillaryA1997 commented 11 months ago

Same here. We can meet tonight.

I suggest 10:30 PM EAT that's 7:30 GMT if am not wrong

On Mon, Dec 4, 2023 at 9:28 AM Ezugwu Chibuike Rufus < @.***> wrote:

Good morning all I think it will be fine if we as a team we have our first call today and then discuss the way forward Thank you

Best regard.

On Mon, Dec 4, 2023, 6:41 AM OmondiHillaryA @.***> wrote:

Probably, Today at 10 PM to 12 PM EAT or Tuesday 7 AM to 10 AM EAT can work for me but stil flexible to reschedule.

On Mon, Dec 4, 2023 at 8:34 AM omondi hillary @.***> wrote:

Good Morning too Rid, I appreciate you contacting us.

Allow me share my Weekly schedule unless things change.

Monday to Friday: 11:30Am to 9PM EAT I attend to part time work. Monday to Friday: Morning hours before 11 AM EAT attend to ALX_SE Curriculum Saturday and Saturday: Fixtures are made depending on how the week has been but having this Collaboration going beyond Codemind Schedule can be beneficial.

Roughly, that how my Weekly Sketch looks like. Regards.

On Mon, Dec 4, 2023 at 8:10 AM AKOREDE RIDWANULLAHI ABIODUN < @.***> wrote:

@LawsonLawson https://github.com/LawsonLawson @Kofi-Awuah2020 https://github.com/Kofi-Awuah2020... Good morning, I trust your night was awesome. The task has been rolled out for us to tackle, I hope we get it done between today and tomorrow, may I know our schedule so that we have our first discussion and share ideas of how we do the task. Looking forward to hearing from you

— Reply to this email directly, view it on GitHub <

https://github.com/codemindshub/liteshell/issues/9#issuecomment-1837853185>,

or unsubscribe <

https://github.com/notifications/unsubscribe-auth/A6FJC5LIW3WQU6POP27BKIDYHVLLBAVCNFSM6AAAAABAFEFBY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZXHA2TGMJYGU>

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub < https://github.com/codemindshub/liteshell/issues/9#issuecomment-1837879498>,

or unsubscribe < https://github.com/notifications/unsubscribe-auth/AMSUMFEFJGL3LS7D24OMJYLYHVPBDAVCNFSM6AAAAABAFEFBY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZXHA3TSNBZHA>

. You are receiving this because you were assigned.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/codemindshub/liteshell/issues/9#issuecomment-1837919681, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6FJC5PNRZBIZNSNFVM7RS3YHVUR5AVCNFSM6AAAAABAFEFBY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZXHEYTSNRYGE . You are receiving this because you commented.Message ID: @.***>

akoredera commented 11 months ago

As we expect Lawson to join the conversation, I hope we are_all satisfied with 19:30GMT for our first discussion?

Likeness30 commented 11 months ago

Yes, looking forward to it!

On Mon, Dec 4, 2023, 12:09 PM AKOREDE RIDWANULLAHI ABIODUN < @.***> wrote:

As we expect Lawson to join the conversation, I hope we are_all satisfied with 19:30GMT for our first discussion?

— Reply to this email directly, view it on GitHub https://github.com/codemindshub/liteshell/issues/9#issuecomment-1838409967, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMSUMFA6C5VHNGFPYI7LSLLYHWVOXAVCNFSM6AAAAABAFEFBY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZYGQYDSOJWG4 . You are receiving this because you were assigned.Message ID: @.***>

Kofi-Awuah2020 commented 11 months ago

Sounds good!

Kofi-Awuah2020 commented 11 months ago

Quick question: On which platform will the meeting be taking place? Also here is my contact details incase anyone wants to reach out: 0241301611 (I use this same number for WhatsApp) kofiawuah.a@gmail.com

akoredera commented 11 months ago

@Kofi-Awuah2020 it's better we have a call, using google meet

akoredera commented 11 months ago

https://meet.google.com/yph-qzsg-huw

akoredera commented 11 months ago

It's almost time let's get set and be available Thanks

akoredera commented 11 months ago

https://meet.google.com/noe-cttf-exs

akoredera commented 11 months ago

char _strtok(char str, const char *delim)

check the first argument (str) if not NULL assigned str to static char input_str; initialize input_str to char token; strchr(input_str, delim[0]) and return the output to char *tempStr check if tempStr is not NULL check the difference between the strlen of input_str and tempStr and save to str_len_diff strncpy(token, input_str, str_len_diff) add null terminator to token - token[str_len_diff] = '\0'; increase tempStr by 1 index; return tempStr value to input_str

nanafox commented 11 months ago

char _strtok(char str, const char *delim)

check the first argument (str) if not NULL assigned str to static char input_str; initialize input_str to char token; strchr(input_str, delim[0]) and return the output to char *tempStr check if tempStr is not NULL check the difference between the strlen of input_str and tempStr and save to str_len_diff strncpy(token, input_str, str_len_diff) add null terminator to token - token[str_len_diff] = '\0'; increase tempStr by 1 index; return tempStr value to input_str

What's this one doing, please? I'm seeing a different function prototype

theAstralProgrammer0 commented 11 months ago