Commit Graph

21 Commits

Author SHA1 Message Date
Qi Xiao
bda2879228 pkg/glob: When enumerating files, keep going if Lstat fails.
When encountering files that can't be lstat'ed, simply ignore them instead of
terminating the entire globbing process. This is consistent with how directories
that can't be read are already silently ignored.

This fixes #1674.
2023-04-10 23:22:21 +01:00
Kurtis Rader
c6e10f12a2 Some minor documentation fixes
Mostly elimination of duplicated words but also a few other fixes such
as the output of commands such as `%`.
2022-08-29 12:04:59 +01:00
Qi Xiao
595f00ae51 pkg/glob: Add a comment on symlink resolution. 2022-08-29 11:51:26 +01:00
Qi Xiao
9ce24d616e Fixup for #1567.
- Don't skip glob_test on Windows.

- Document the change as a breaking change.
2022-08-28 21:55:56 +01:00
Kurtis Rader
a72224d7f0 Fix glob expansion that includes broken symlinks
Glob expansion should use os.Lstat rather than os.Stat so that broken
symlinks don't stop glob expansion. It's not the place of glob expansion
to decide if a particular path is good.

The symlink test cases and logic were borrowed from
pkg/mods/path/path_test.go.

Fixes #1240
2022-08-28 21:46:39 +01:00
Kurtis Rader
383b083760 Replace remaining deprecated ioutil.ReadDir uses
Resolves #1350
2021-08-30 08:57:34 +01:00
Qi Xiao
e9d328aa16 Make use of (*testing.T).Cleanup for test cleanups.
This allows turning the following pattern in tests:

  value, cleanup := setupSomething()
  defer cleanup()

into the following:

  value := setupSomething(t)
2021-08-06 23:21:23 +01:00
Qi Xiao
d81bfa69f0 Fix handling of Windows in TestGlob_InvalidUTF8InFilename. 2021-06-09 00:57:36 +01:00
Qi Xiao
bcaa8f5cbf Actually make the test reproduce the crash described in #1220.
The crash doesn't happen right now because the code has been fixed, but the test will
reproduce the crash if the change in glob.go is reverted.
2021-06-09 00:40:55 +01:00
Qi Xiao
941cdf2cdf Fix crash when globbing files with invalid UTF-8 sequences.
This fixes #1220.
2021-06-09 00:36:45 +01:00
Qi Xiao
246c4741c2 Also skip the test if the OS creates the file but mangles the name. 2021-06-09 00:36:18 +01:00
Qi Xiao
e9bcb737ab Make test case crashing too. 2021-06-09 00:31:26 +01:00
Qi Xiao
cfc8f0fe69 Add (failing) regression test for #1220. 2021-06-09 00:10:12 +01:00
Qi Xiao
69e9130cf5 pkg/glob: Update TODO about path separator on Windows. 2021-06-06 14:36:38 +01:00
Kurtis Rader
181b663c6a Fix isDrive
I was looking at "TODO" comments that could be eliminated and noticed the
one preceding the sole use of `isDrive()`. Which caused me to notice its
implementation is broken. The `s[1] < 'z'` test should be `s[0] < 'z'`
2021-06-06 14:34:23 +01:00
Qi Xiao
196eea21d4 Change module import path to src.elv.sh 2021-01-27 01:30:25 +00:00
Qi Xiao
48919bcb24 pkg/: Move test utilities from util/ to testutil/. 2020-09-03 04:55:16 +01:00
Kurtis Rader
28798ac053 Convert "XXX" to "TODO" comments
I stumbled across a comment that began with "XXX". It was clearly meant as
a "TODO" comment. This changes all such occurrences. However, a few "XXX"
comments are ambiguous and a better prefix might be "WARNING". The "TODO"
prefix at least ensures someone, eventually, looks into the situation
and either rewords the comment or fixes the problem. This change means
everyone can assume searching for "// TODO" will find all such comments
rather than requiring they also know to search for "// XXX".
2020-08-16 16:29:34 +01:00
Qi Xiao
088190b4a5 Address remaining feedback of #1018. 2020-06-28 01:33:27 +01:00
Kurtis Rader
e8a8ee04b8 Add a wildcard [type:xxx] modifier
This allows filtering the wildcard expansion by path type. For example,
whether the path is a directory, regular file, or something else. So
instead of `find . -type f` you can now do `**[type:file]`.

Resolves #1015
2020-06-28 01:25:32 +01:00
Qi Xiao
e45fdf7228 Move all libraries to new pkg/. 2019-12-23 20:00:59 +00:00