1 |
On Tue, 29 May 2012 14:50:19 +0100 |
2 |
Steven J Long <slong@××××××××××××××××××.uk> wrote: |
3 |
|
4 |
> Michał Górny wrote: |
5 |
> |
6 |
> > + find "${D}" -type f -name '*.la' -print0 | while read -r -d '' |
7 |
> > f; |
8 |
> .. |
9 |
> > + rm -f "${f}" || die |
10 |
> .. |
11 |
> > + done |
12 |
> |
13 |
> Don't pipe to read like that; it means the final command is in a |
14 |
> subshell and "die is /not/ guaranteed to work correctly if called |
15 |
> from a subshell environment."[1] |
16 |
|
17 |
Didn't we actually change that in the past? I think I'm recalling |
18 |
something like that... |
19 |
|
20 |
> More seriously, the script doesn't actually get the correct |
21 |
> filenames, despite being written to handle any filename. |
22 |
> eg: |
23 |
> $ touch $' foo bar \n\t ' |
24 |
> $ while read -r -d '' f; do echo "'$f'"; done < <(find . -type f |
25 |
> -print0) './ foo bar' |
26 |
> |
27 |
> You do it like this: |
28 |
> |
29 |
> while read -rd ''; do |
30 |
> f=$REPLY; |
31 |
> .. |
32 |
> done < <(find "$D" -type f -name '*.la' -print0) |
33 |
|
34 |
Thanks. |
35 |
|
36 |
-- |
37 |
Best regards, |
38 |
Michał Górny |