1 |
On 29-03-2011 22:35:48 -0600, Ryan Hill wrote: |
2 |
> > Because 'ls' would complain that files didn't exist, such as lib*.dylib |
3 |
> > when on a Linux system. It doesn't matter. But, using 'find' avoids this |
4 |
> > mess. |
5 |
> |
6 |
> Never use ls to get filenames in a script. Instead of |
7 |
> |
8 |
> for link_source in $(eval ls ${source_dir} 2> /dev/null) ; do |
9 |
> |
10 |
> just use |
11 |
> |
12 |
> for link_source in "${source_dir}"/* ; do |
13 |
> |
14 |
> I see you already fixed this one, but you do some funky stuff with ls -d |
15 |
> earlier on. |
16 |
|
17 |
Make sure though, when you use a glob, that you check for the asterisk. |
18 |
|
19 |
When there are no matches, bash assumes you meant the literal '*' and |
20 |
hence will return "/foo/bar/*" in link_source. |
21 |
So make sure you check the existence of whatever is in link_source |
22 |
before using it. |
23 |
|
24 |
|
25 |
-- |
26 |
Fabian Groffen |
27 |
Gentoo on a different level |