Commit ce9a467
committed
Return empty list on invalid globs
Regression was introduced in 9479c28.
Since that commit, providing an invalid glob to tera will make it fail
to create an instance, first (in that commit) by making it panic and
since 1f95878 by making it return an
error.
While returning an error is not entirely unlogical, it doesn't match
what most languages do with invalid globs.
- Bash will by default return an empty set on invalid globs, as the
`failglob` option is off by default
- Python will likewise return the empty set instead of throwing an
exception, when doing something like `glob.glob("/dev/null/*")`
- Rust's `globwalk` will also not error, but return an empty set
In fact, we use globwalk in tera and the only reason we panic is by
accident, because `std::fs::canonicalize()` checks the path.
It is better to match other language's glob behaviour, therefore we
resort back to the original path if `canonicalize()` fails.
We should especially restore the previous behaviour, as this caused a
lot of regressions already, including in zola.
Fixes getzola/zola#2150
ref: Keats#819
ref: Keats#820
ref: Keats#7991 parent 1f95878 commit ce9a467
1 file changed
+10
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
136 | 142 | | |
137 | 143 | | |
138 | 144 | | |
| |||
1222 | 1228 | | |
1223 | 1229 | | |
1224 | 1230 | | |
1225 | | - | |
| 1231 | + | |
1226 | 1232 | | |
1227 | 1233 | | |
1228 | | - | |
| 1234 | + | |
| 1235 | + | |
1229 | 1236 | | |
1230 | 1237 | | |
0 commit comments