-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] Implement wildcard expansion for the current directory #292
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
itislu
force-pushed
the
feat-wildcard-expansion
branch
from
March 30, 2024 21:49
3acdf70
to
7c32b64
Compare
LeaYeh
force-pushed
the
feat-wildcard-expansion
branch
from
March 31, 2024 18:29
aa251be
to
d80bd98
Compare
itislu
force-pushed
the
feat-wildcard-expansion
branch
5 times, most recently
from
April 1, 2024 10:04
913c611
to
eb7b041
Compare
1 task
1 task
TODO: - Don't expand '*' if it is quoted. - Remove quotes from the pattern to match filenames against. - Filename list sorting is not correct yet.
This is to better differentiate between the `t_expander_task` type and `t_list` type.
BUG: This breaks the behavior of quotes that come from variable expansions, as was already solved in PR #177. - Add wildcard tasks to task list to be able to differentiate which asterisks should be expanded and which ones not bc they were quoted. - Append quote tasks only after parameter expansion together with wildcard tasks. This is so that the wildcard tasks can be appended to the task list in correct order with the quote tasks. Otherwise, it would cause issues with the current implementation of how updating the task_list works after an expansion. - Also fix norminette for wildcard expansion and separate new functions into other files.
- Revert back to adding the quote tasks together with the variable expansion tasks in order to not take quotes that came from variable expansion into consideration. - In order to keep the quote interaction with wildcards correct (only quotes that were in the string before variable expansion should effect wildcard expansion), when searching every character of all words for a '*', search for quotes, and if one is found, check the task_list if the current character is part of a task and move the first node from the old task list to the new task list. At this stage there should be only quote tasks in the old task list, so after this, all nodes of the old task list should have been moved to the new task list, with new wildcard tasks inserted correctly.
1. Compare considering only alphanumeric, not considering case. 2. If equal so far, lowercase before uppercase. 3. If equal still, give priority to non-alphanumeric. 4. If both are non-alphanumeric, just check which has lower ASCII value.
Also reduce 2 unnecessary lines in `expand_wildcard()`.
Also change `any_wildcard_task()` to `any_task_of_type()` for more general use.
It contained a lot of tricky filenames, so it's good to keep it in the history.
itislu
force-pushed
the
feat-wildcard-expansion
branch
from
April 1, 2024 13:17
eb7b041
to
632a501
Compare
itislu
changed the title
[FEAT] Implement wildcard expansion
[FEAT] Implement wildcard expansion for the current directory
Apr 1, 2024
@LeaYeh I left the function name as |
LeaYeh
approved these changes
Apr 1, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Matching filenames
*
within any quotes should not get expanded and should just match the literal character*
..
have to be matched explicitely, like with.*
.This means, even tough filename expansion occurs before quote removal,
*"fi"le
should not try to match<anything>"fi"le
, but<anything>file
. (reference)Order of filenames
The order of the filenames that match exactly immitates bash's sorting order for ASCII characters, following these rules revealed by testing:
However, bash itself uses a much more complicated system called collation, where each unicode character has specific a place in a list of all characters.
This list can be viewed from this path:
For all possible characters from the German keyboard, the order is as follows:
In C there is a function that can handle this collating called
strcoll()
.For more great information:
https://unix.stackexchange.com/questions/423345/generate-collating-order-of-a-list-of-individual-characters
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_02
Known issue: [KNOWN ISSUE] Word splitting and filename expansion should not be performed when assigning values to variables #295
Resolves [EXPLANATION] Wildcard behavior #107 (many tricky test cases listed in the issue)
Test cases