Skip to content

Implementing the alias command#28

Draft
theAstralProgrammer0 wants to merge 9 commits intomasterfrom
ty_alias
Draft

Implementing the alias command#28
theAstralProgrammer0 wants to merge 9 commits intomasterfrom
ty_alias

Conversation

@theAstralProgrammer0
Copy link
Collaborator

  • I added the first three auxiliary functions required to implement an aliasExecutor function that is yet to be programmed.

  • I also added a function that finds the length of a string array - a basic word counter - which will be of utility when building the aliasExecutor function.

@theAstralProgrammer0 theAstralProgrammer0 marked this pull request as draft December 4, 2023 21:54
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm yet to fully understand what this function does. Could you throw more light on this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Right, so the str_arr_size function can be used to get the length of a NULL terminated string array.
  • After tokenizing a string into a string array, we can utilize this function to find how many strings exist in the array.
  • For instance, in the aliasExecutor function I'm currently working on, I can use this function to find the length of any string array returned by the strtow function.
  • I will be using the strtow function heavily, and it would be useful to know the length of the returned string array - particularly when writing if conditions

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another team will be handling the tokenizer function #9 so you could rest on this one unless you have a specific use case.
You can check out their tokenizer function to learn more about how it could fit into your needs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Alright boss, thanks. I'll look into their function. However, their tokenize function can only help create the string array. It does not provide the size of the array for future use.
  • The str_arr_size function will help count the number of strings present in a string array that's returned from the tokenize function, which I will need in my function implementation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to check your line 16 well...

Also, I'd like to believe memory is correctly handled in your code logic.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, in your addAlias() function, you keep adding to the beginning of the list which will influence how the list of aliases is printed out when the command alias is issued without arguments. Utilize the tail pointer, it also gives you an O(1) runtime.

Currently, your code logic does not account for when alias is issued without arguments. Look into that, it's supposed to print the list of aliases in that case.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compare how sh prints the aliases, it doesn't include the alias keyword in the output. Handle the errors properly with the right error codes and messages. Consult with sh.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, in your addAlias() function, you keep adding to the beginning of the list which will influence how the list of aliases is printed out when the command alias is issued without arguments. Utilize the tail pointer, it also gives you an O(1) runtime.

Currently, your code logic does not account for when alias is issued without arguments. Look into that, it's supposed to print the list of aliases in that case.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compare how sh prints the aliases, it doesn't include the alias keyword in the output. Handle the errors properly with the right error codes and messages. Consult with sh.

Debugged addAlias function taking into account the tail member of an aliasList
Adjusted aliasExecutor function to account for changes in initAlias, and addAlias functions
Corrected other errors in alias.c
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have concerns with the alias functions...

Could you share a screenshot of the result after testing this function?
Also, share the file that you used for the testing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright boss.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants