-
Notifications
You must be signed in to change notification settings - Fork 3
/
todo
72 lines (51 loc) · 2.46 KB
/
todo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# wildcard expansion:
- [x] Get a list of all files of the current directoy.
- [x] Rename `lst` to `expanded_list` in expander.
- [x] Rename `E_EXPAND` to `E_PARAM` or `E_VAR`.
- [x] Check op_masks WHEN wildcard expansion should happen!
- [ ] Not for values when assigning env variables.
- [x] Not in heredoc content.
### Sorting
- Numeric before alphabetic.
- Lowercase before uppercase.
- First, only consider alphanumeric. If that is equal, non-alphanumeric comes first and is sorted by ASCII value.
- Entirely non-alphanumeric comes very first.
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.
### Matching
- [x] Don't expand '*' if it is quoted.
- [x] Remove quotes from the pattern to match filenames against:
> If any character (ordinary, shell special, or pattern special) is quoted, that pattern shall match the character itself.
### Framework
- [x] Search each word of `lst` for '*'.
- [x] If found, set a new `tmp_lst` variable to NULL and go to other function which sets the `tmp_lst`.
Then, if `tmp_lst` is still NULL, do nothing and go to next word.
Else, drop that word and insert the `tmp_lst` before the new current node.
- [x] If a filename matches, ft_strdup the filename and append a node with it to `tmp_lst`.
//- [ ] When searching each word for '*' and one is found, first check if that index is within quote tasks.
If it is, skip until next quote task.
- "." and ".." don't have to be filtered, bash also displays them.
- [x] Only search files starting with "." if the first character of arg is also '.'.
- [x] Test with files that have no permissions.
If the end of the directory stream is reached, NULL is returned and errno is not changed. If
an error occurs, NULL is returned and errno is set appropriately. To distinguish end of
stream from an error, set errno to zero before calling readdir() and then check the value of
errno if NULL is returned.
- Filenames can still be read even of files that have no read permissions.
- Wildcard at first and last position have a high impact.
### Test cases
export A=$
echo "$A"USER
export A="*"
echo $A""
echo *""file
echo *"f"ile
echo *"*"*
echo *" "*
export B="a b c Make"
echo ""$B""*$B*""
echo "*"*""*
echo *"*"*""**
echo "M"*"e"