1 |
Dnia 2014-11-23, o godz. 10:23:27 |
2 |
Zac Medico <zmedico@g.o> napisał(a): |
3 |
|
4 |
> On 11/23/2014 01:09 AM, Michał Górny wrote: |
5 |
> >>> + # Collect file names of QA checks. We need them early to support |
6 |
> >>> + # overrides properly. |
7 |
> >>> + for d in "${paths[@]}"; do |
8 |
> >>> + for f in "${d}"/*; do |
9 |
> >>> + [[ -f ${f} ]] && qa_checks+=( "${f##*/}" ) |
10 |
> >>> done |
11 |
> >>> done |
12 |
> >>> |
13 |
> >>> + # Now we need to sort the filenames lexically, and process |
14 |
> >>> + # them in order. |
15 |
> >>> + while IFS= read -r -d '' f; do |
16 |
> >> |
17 |
> >> I'm not sure how IFS is relevant here. Please clarify. |
18 |
> > |
19 |
> > Unsetting IFS prevents word splitting. Otherwise just the first word |
20 |
> > would get assigned to f and others discarded. |
21 |
> |
22 |
> Can you create a test case to demonstrate why it's needed? I created |
23 |
> this test case that seems to work fine without changing IFS: |
24 |
> |
25 |
> qa_checks=("d e f" "a b c") |
26 |
> |
27 |
> while read -r -d '' f; do |
28 |
> echo "$f" |
29 |
> done < <(printf "%s\0" "${qa_checks[@]}" | LC_ALL=C sort -u -z) |
30 |
|
31 |
You are correct and I were wrong. I've tested even fancy cases like |
32 |
' foo bar baz ' and it seems that all of them work correctly |
33 |
without IFS= substitution. |
34 |
|
35 |
I'm going to send an updated patch in a few minutes. |
36 |
|
37 |
-- |
38 |
Best regards, |
39 |
Michał Górny |